随笔分类 - 数论
摘要:思路:把【1,1e8】分成每50一个区间,然后打表记录是第几个50,出的部分之间枚举,不会超过50,就是打表速度略蛋疼。 1 #include <iostream> 2 #include <queue> 3 #include <stack> 4 #include <cstdio> 5 #includ
阅读全文
摘要:1 const int S = 20;//随机算法判定次数,S越大,判错概率越小 2 LL pow_mod(LL a, LL b, LL mod) { // a^b%mod 3 LL ans = 1; 4 a = a % mod; 5 while(b) { 6 if(b & 1) { 7 ans = (ans * a)...
阅读全文
摘要:题意:求a^b的所有约数和对1e9+7取模的结果 思路:对于一个数p,进行唯一分解,则p=P1^M1*P2^M2*...*Pn^Mn,则p的所有约数之和等于(P1^0+P1^1+...+P1^M1)*(P2^0+P2^1+...+P2^M2)*...*(Pn^0+Pn^1+...+Pn^Mn), p
阅读全文
摘要:题意:给你一个集合,让你找到一个最大的子集,使得子集里面的元素的gcd!=1,输出子集的元素的个数。 思路:先将集合里面的元素哈希,再线性筛。 PS:明明以前做过类似的题的,结果又忘了,卡了好久最后打表过的。 1 #include <iostream> 2 #include <queue> 3 #i
阅读全文

浙公网安备 33010602011771号