摘要:额随机开了场多校,做到第二题傻眼了。。这么大的数据搞毛线===试着来了一发暴力T了,没有尝试随机(我来瞅瞅题解==看到了新的算法,哎欠的终究要补,把Miller_Rabin和Pollard_rho算法看了一晚上---->并看不懂2333其实大部分还是可以看懂的,主要就是Miller_Rabin那里的...
阅读全文
摘要:(a/b) mod m:gcd(b,m) = 1 求b相对m的逆元b^(-1),即b*(b^(-1))= 1 (mod m),然后计算a*b^(-1) mod m,其值与(a/b) mod m相同gcd(b,m)!=1 不可以用逆元了,倒可以把a/b分解质因数相乘,然后快速幂,将除法取模转化为乘...
阅读全文
摘要:额现在才补==这题当时是cp各种姿势打表发现的==然后我大胆用了类似筛法写了一下,竟然给过了==规律:如果gcd(a, b) = xor(a, b) = c, 则 c = a - b然后就能利用c来筛了 1 #include 2 #include 3 int vis[30000005],sum[30...
阅读全文
摘要:公式如上,dfs函数思考清楚==另外欧拉函数以前写的可以换了 1 #include 2 #include 3 #include 4 #define LL long long 5 LL phi(LL x) 6 { 7 LL ans=x,i; 8 for (i=2;i*i=m) return a...
阅读全文
摘要:从爱神那看的中国剩余定理解法,挺容易理解的,就是一个循环迭代更新下去细节还是很重要! 1 #include 2 #include 3 #define LL long long 4 void exgcd(LL a,LL b,LL& d,LL &x,LL &y) 5 { 6 if (!b) {d...
阅读全文
摘要:想到了用容斥简化题目,也想倒如何去算大区间的方案,最后对两个遗留串处理纠结了太久!!帅bin ac后我看了别人题解,真的只是细节讨论那儿处理的失误TAT哎自己傻逼又没写出来! 1 #include 2 #include 3 #include 4 using namespace std; 5 #def...
阅读全文
摘要:积性函数定义:f(1)=1,当a,b互质时f(ab)=f(a)f(b)。eg:1.f[n]:n的正因子个数 2.f[n]:n的正因子之和 3.gcd(n,k) k固定时n与k的最大公约数 4.φ(n) n的欧拉函数值(即小于n且与n互质数的数目)此题满足第二个,即可拆分成几个素数,然后用等比数...
阅读全文
摘要:1 #include 2 #include 3 int vis[100005],prime[100005]; 4 int main() 5 { 6 int cnt,dd,i,j,t,T,n,ans,temp; 7 cnt=0; dd=int(1.0*sqrt(1000000000....
阅读全文
摘要:1 #include 2 long long gcd(long long a,long long b) 3 { 4 if (b==0) return a; 5 return(gcd(b,a%b)); 6 } 7 int main() 8 { 9 long long m,n;...
阅读全文