
数论
文章平均质量分 78
心脏dance
求关注!!!求关注!!!安卓、后端学习记录,面试算法题(博主ACM区域赛银牌~~~水银嘻嘻~~~,蓝桥杯国一~~~),面试技术题。如果觉得博主写的好,菜鸡博主求关注~~~。 /*
呜呜呜~~大学的时候,写的博文中有些是借鉴的,若有侵权,请告知,立马删除。。。。 */
展开
-
小红的375(思维+数学)
题目链接:登录—专业IT笔试面试备考平台_牛客网牛客网是互联网求职神器,C++、Java、前端、产品、运营技能学习/备考/求职题库,在线进行百度阿里腾讯网易等互联网名企笔试面试模拟考试练习,和牛人一起讨论经典试题,全面提升你的技术能力https://ac.nowcoder.com/acm/contest/11218/F题目描述小红拿到了一个正整数。她希望你能重排这个正整数的数位,使得它能被 375 整除。你能帮帮她吗?输入描述:一个正整数,大小不超过 10^{300000}输出描述:原创 2021-12-05 13:20:05 · 1416 阅读 · 0 评论 -
洛谷 p4195—— 【模板】exBSGS/Spoj3105 Mod(BSGS)
题目描述已知数a,p,b,求满足a^x≡b(mod p)的最小自然数x。输入格式每个测试文件中最多包含100组测试数据。每组数据中,每行包含3个正整数a,p,b。当a=p=b=0时,表示测试数据读入完全。输出格式对于每组数据,输出一行。如果无解,输出“No Solution”(不含引号),否则输出最小自然数解。输入输出样例输入 #1复制5 58 33...原创 2019-12-30 15:21:03 · 214 阅读 · 0 评论 -
牛客——[SDOI2011]计算器(快速幂+扩展欧几里得+BSGS)
链接:https://ac.nowcoder.com/acm/problem/20347来源:牛客网时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 262144K,其他语言524288K64bit IO Format: %lld题目描述你被要求设计一个计算器完成以下三项任务:1、给定y,z,p,计算Y^Z Mod P 的值;2、给定y,z,p,计算满...原创 2019-12-30 15:21:15 · 876 阅读 · 0 评论 -
牛客——[SDOI2013]随机数生成器(推公式+BSGS)
链接:https://ac.nowcoder.com/acm/problem/20362来源:牛客网时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 262144K,其他语言524288K64bit IO Format: %lld题目描述小W喜欢读书,尤其喜欢读《约翰克里斯朵夫》。最近小W准备读一本新书,这本书一共有P页,页码范围为0⋯P−1。小W很忙,所以每...原创 2019-12-29 20:55:46 · 249 阅读 · 0 评论 -
LibreOJ——#6053. 简单的函数(Min_25筛)
题意:不解释题解:暂时没看懂,应该是板子题上代码:(别人写的)#include<bits/stdc++.h>using namespace std; typedef long long ll;const int N=2e5+5,D=1e9+7;ll n;int sqrt_n;int m;ll w[N],s0[N],s1[N];int s[...原创 2019-12-29 20:55:22 · 156 阅读 · 0 评论 -
杭电2019多校第一场 HDU——6579 Operation(线性基)
时间限制: 1 Sec内存限制: 128 MB[提交] [状态] [命题人:admin]题目描述There is an integer sequence a of length n and there are two kinds of operations:0 l r: select some numbers from al...ar so that their xor s...原创 2019-07-23 15:10:55 · 321 阅读 · 0 评论 -
CodeForces ——1100F Ivan and Burgers(线性基)
Ivan loves burgers and spending money. There arennburger joints on the street where Ivan lives. Ivan hasqqfriends, and theii-th friend suggested to meet at the jointliliand walk to the jointrir...原创 2019-07-23 15:26:32 · 242 阅读 · 0 评论 -
杭电2019多校第五场 HDU——6624 fraction(辗转相除法)
Many problems require printing the probability of something. Moreover, it is common that if the answer isabab, you should outputa×b−1(modp)a×b−1(modp)(ppis a prime number). In these problems, you ...原创 2019-08-06 16:19:40 · 208 阅读 · 0 评论 -
HDU——3930(N次剩余)
There is a way of encryption in the Digital planet. If the number x, who lives in M area, K layer, then it will change its name to x ^ K mod M, that is newx = x ^ k mod m. Now the Digital Kingdom want...原创 2019-12-29 20:55:21 · 612 阅读 · 0 评论 -
2019牛客暑期多校训练营(第七场)I——Chessboard(思维+组合数)
链接:https://ac.nowcoder.com/acm/contest/887/I来源:牛客网时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 32768K,其他语言65536K64bit IO Format: %lld题目描述CSL likes playing tricks very much. The unlucky TL always becomes ...原创 2019-08-09 14:20:28 · 202 阅读 · 0 评论 -
Comet OJ - Contest #8 神奇函数(积性函数)
题意:求上面那个函数的值,题目很清楚题解:欧拉函数的应用,首先我们要把上面那个式子换成我们熟悉能用代码写的复杂度小的形式,因为题目中的条件是除以最小质因子(显然),我们考虑把x换成下面这个形式:那么我们经过推导很容易得出 然后我们知道欧拉函数的性质(与质数有关的函数考虑欧拉函数):然后把n换成f(x) :因为x=f(x)^2而且f(x)是d...原创 2019-08-20 15:34:11 · 554 阅读 · 0 评论 -
银联高校极客挑战赛 复赛(A,B,思维+数学)
A题目描述现在已经是暑假了!这周日,码队的弟弟所在的班级——上海某中学高二33班的同学们准备在码队弟弟的带领下(码队的弟弟是这个班的班长),举办一场派对。码队的弟弟让两名同学打开手机「云闪付」app,在云闪付在线商城上采购饮料。经过这两名同学统计,发现一共需要买nn瓶饮料。而在云闪付在线商城上,一共有mm种不同的饮料(包括「肥宅快乐水」,并假设云闪付在线商城上的每种饮料的...原创 2019-08-11 19:31:32 · 406 阅读 · 1 评论 -
2019牛客暑期多校训练营(第九场)B——Quadratic equation(二次剩余)
链接:https://ac.nowcoder.com/acm/contest/889/B来源:牛客网时间限制:C/C++ 2秒,其他语言4秒空间限制:C/C++ 262144K,其他语言524288K64bit IO Format: %lld题目描述Amy asks Mr. B problem B. Please help Mr. B to solve the follow...原创 2019-08-16 12:35:52 · 418 阅读 · 0 评论 -
HDU——3977 Evil teacher(求斐波那契数列循环节)
题意:求斐波那契数列模一个数的循环节的长度。其中模的那个数的最大值<=2e9 但是这个数的最大质因子<=1e6题解:我这个菜鸡就把这个当成板子了,想研究的大佬请看https://blog.youkuaiyun.com/h6363817/article/details/11017111上代码:#include <iostream>#include <cstdio&...原创 2019-08-16 15:30:51 · 292 阅读 · 0 评论 -
2019牛客暑期多校训练营(第九场)A——The power of Fibonacci(循环节+中国剩余定理(互质)||广义BM)
链接:https://ac.nowcoder.com/acm/contest/889/A来源:牛客网时间限制:C/C++ 2秒,其他语言4秒空间限制:C/C++ 262144K,其他语言524288K64bit IO Format: %lld题目描述Amy asks Mr. B problem A. Please help Mr. B to solve the follow...原创 2019-08-16 17:06:39 · 285 阅读 · 0 评论 -
2019牛客暑期多校训练营(第二场)A——Eddy Walker(逆元+找规律)
链接:https://ac.nowcoder.com/acm/contest/882/A来源:牛客网时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 262144K,其他语言524288K64bit IO Format: %lld题目描述Eddy likes to walk around. Especially, he likes to walk in a loo...原创 2019-07-21 09:47:49 · 315 阅读 · 1 评论 -
POJ——2478 Farey Sequence(欧拉函数)
The Farey Sequence Fn for any integer n with n >= 2 is the set of irreducible rational numbers a/b with 0 < a < b <= n and gcd(a,b) = 1 arranged in increasing order. The first few areF2 ...原创 2019-07-19 20:09:13 · 192 阅读 · 0 评论 -
LightOJ ——1282 (简单数论+技巧)
You are given two integers:nandk, your task is to find the most significant three digits, and least significant three digits ofnk.InputInput starts with an integerT (≤ 1000), denoting the num...原创 2019-07-19 15:08:09 · 533 阅读 · 1 评论 -
Applese 涂颜色 (欧拉函数降幂)
链接:https://ac.nowcoder.com/acm/contest/330/E来源:牛客网时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 262144K,其他语言524288K64bit IO Format: %lld题目描述精通程序设计的 Applese 叕写了一个游戏。在这个游戏中,有一个 n 行 m 列的方阵。现在它要为这个方阵涂上黑白两种...原创 2019-01-29 19:55:43 · 248 阅读 · 0 评论 -
小a与黄金街道(欧拉函数求互质和)
链接:https://ac.nowcoder.com/acm/contest/317/D来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 32768K,其他语言65536K64bit IO Format: %lld题目描述小a和小b来到了一条布满了黄金的街道上。它们想要带几块黄金回去,然而这里的城管担心他们拿走的太多,于是要求小a和小b通过做一个游戏来...原创 2019-01-29 20:33:23 · 214 阅读 · 0 评论 -
POJ——3696 The Luckiest number(欧拉函数+骚快速幂)
The Luckiest numberChinese people think of '8' as the lucky digit. Bob also likes digit '8'. Moreover, B...原创 2018-07-26 20:59:36 · 381 阅读 · 1 评论 -
HDU——1576 A/B(逆元)
要求(A/B)%9973,但由于A很大,我们只给出n(n=A%9973)(我们给定的A必能被B整除,且gcd(B,9973) = 1)。Input数据的第一行是一个T,表示有T组数据。 每组数据有两个数n(0 <= n < 9973)和B(1 <= B <= 10^9)。Output对应每组数据输出(A/B)%9973。Sample Input2...原创 2018-08-25 16:18:10 · 207 阅读 · 0 评论 -
ZOJ——3609 Modular Inverse(逆元)
The modular modular multiplicative inverse of an integer a modulo m is an integer xsuch that a-1≡x (mod m). This is equivalent to ax≡1 (mod m).InputThere are multiple test cases. The first line of...原创 2018-07-27 11:19:33 · 233 阅读 · 0 评论 -
Applese 的大奖 (费马小定理求逆元)
链接:https://ac.nowcoder.com/acm/contest/330/H来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 262144K,其他语言524288K64bit IO Format: %lld题目描述Applese 和它的小伙伴参加了一个促销的抽奖活动,活动的规则如下:有一个随机数生成器,能等概率生成 0∼99 之间的整数...原创 2019-01-30 16:09:20 · 283 阅读 · 0 评论 -
Rinne Loves Xor (数论,Xor)
链接:https://ac.nowcoder.com/acm/contest/370/I来源:牛客网 时间限制:C/C++ 2秒,其他语言4秒空间限制:C/C++ 262144K,其他语言524288K64bit IO Format: %lld题目描述Rinne 最近学习了位运算相关的知识,她想运用自己学习的知识发明一个加密算法。首先她有一个源数组 A,还有一个密钥数组 B,...原创 2019-02-10 14:33:28 · 326 阅读 · 0 评论 -
qdu 2017级纳新题(扩展欧几里得)
在你面前撒个娇 哎呦喵喵喵喵喵Description 我们一起学猫叫一起喵喵喵喵喵在你面前撒个娇哎呦喵喵喵喵喵我的心脏砰砰跳迷恋上你的坏笑你不说爱我我就喵喵喵每当xjy和hqy一起唱起这首歌时,就会吸引好多猫群来听歌,这天他们又吸引来n群猫。每个猫群里都分为雄猫和雌猫,第一个猫群里有1只雄猫和n只雌猫,第二个猫群里有2只雄猫和n-1只雌猫....第n个猫...原创 2018-08-27 11:13:25 · 579 阅读 · 0 评论 -
小咪买东西(最大化平均值+二分)
链接:https://ac.nowcoder.com/acm/problem/14662来源:牛客网时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 131072K,其他语言262144K64bit IO Format: %lld题目描述小咪是一个土豪手办狂魔,这次他去了一家店,发现了好多好多(n个)手办,但他是一个很怪的人,每次只想买k个手办,而且他要让他花的每...原创 2019-02-28 14:28:00 · 683 阅读 · 0 评论 -
小爱密码——小米 OJ 编程比赛 02 月常规赛(矩阵快速幂+欧拉降幂)
小爱密码序号:#137 难度:困难 时间限制:1000ms 内存限制:80M描述小爱同学有一个智能密码锁。锁上有九位数字,小爱同学每次会给A,B,C,D,mod,n六个正整数。 题目是这样的:F(1) = A, F(2) = BF(n) = F(n-1)*F(n-2)*C^D(n>2)现在小爱同学想计算出G(n) 的值(G(n)为F...原创 2019-03-06 16:30:18 · 653 阅读 · 0 评论 -
ZOJ——2955 Interesting Dart Game (鸽巢原理)
Recently, Dearboy buys a dart for his dormitory, but neither Dearboy nor his roommate knows how to play it. So they decide to make a new rule in the dormitory, which goes as follows:Given a numberN...原创 2019-03-30 22:08:06 · 277 阅读 · 0 评论 -
HDU——6189 Law of Commutation(数论+打表找规律)
As we all know, operation ''+'' complies with the commutative law. That is, if we arbitrarily select two integersaaandbb,a+ba+balways equals tob+ab+a. However, as for exponentiation, such law ma...原创 2019-04-10 12:46:15 · 337 阅读 · 0 评论 -
HDU——5528 Count a * b(积性函数推公式+唯一分解定理)
Marry likes to count the number of ways to choose two non-negative integersaaandbbless thanmmto makea×ba×bmodm≠0m≠0.Let's denotef(m)f(m)as the number of ways to choose two non-negative int...原创 2019-06-27 16:21:21 · 256 阅读 · 0 评论 -
2019年第二阶段我要变强个人训练赛第十二场——H 计数JS(容斥定理傻蛋题)
问题 H: 计数JS问题 H: 计数JS时间限制: 1 Sec内存限制: 128 MB提交: 219解决: 26[提交] [状态] [命题人:admin]题目描述给定一个长度为n的序列a1..an,求m以内的不能被a1..an中任意一个ai整除的正整数有多少个?输入第一行两个数n,m接下来一行n个数,a1..an输出共一个数,...原创 2019-07-09 13:56:52 · 241 阅读 · 0 评论 -
炫酷数字 (扩展埃式筛法)
链接:https://ac.nowcoder.com/acm/contest/331/G来源:牛客网 时间限制:C/C++ 2秒,其他语言4秒空间限制:C/C++ 131072K,其他语言262144K64bit IO Format: %lld题目描述小希希望你构造一个最小的正整数,使得其有n个因子。输入描述:第一行一个整数T表示数据组数每组数据第一行输入一个正整...原创 2019-02-01 10:20:47 · 251 阅读 · 0 评论