文章分类 -  acm数论

hdu3864 Miller_Rabin快速判断素数&Pollard_rho快速分解素因数
摘要:额随机开了场多校,做到第二题傻眼了。。这么大的数据搞毛线===试着来了一发暴力T了,没有尝试随机(我来瞅瞅题解==看到了新的算法,哎欠的终究要补,把Miller_Rabin和Pollard_rho算法看了一晚上---->并看不懂2333其实大部分还是可以看懂的,主要就是Miller_Rabin那里的... 阅读全文

posted @ 2015-04-30 01:48 xiao_xin 阅读(187) 评论(0) 推荐(0)

C(n,m)%p n,m<=10^5,p<=10^9 p非质数
摘要:(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分解质因数相乘,然后快速幂,将除法取模转化为乘... 阅读全文

posted @ 2015-04-13 16:11 xiao_xin 阅读(237) 评论(0) 推荐(0)

uva12716 n以内有多少对整数a、b满足(1≤b≤a)且gcd(a, b) = xor(a, b)
摘要:额现在才补==这题当时是cp各种姿势打表发现的==然后我大胆用了类似筛法写了一下,竟然给过了==规律:如果gcd(a, b) = xor(a, b) = c, 则 c = a - b然后就能利用c来筛了 1 #include 2 #include 3 int vis[30000005],sum[30... 阅读全文

posted @ 2015-03-01 22:39 xiao_xin 阅读(360) 评论(0) 推荐(0)

hdu2837(2009多校第三场) a^b%p=a^(b%phi(p)+phi(p))%p b>=phi(p)
摘要:公式如上,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... 阅读全文

posted @ 2014-12-11 02:06 xiao_xin 阅读(250) 评论(0) 推荐(0)

hdu1573 中国剩余定理
摘要:从爱神那看的中国剩余定理解法,挺容易理解的,就是一个循环迭代更新下去细节还是很重要! 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... 阅读全文

posted @ 2014-11-07 12:13 xiao_xin 阅读(104) 评论(0) 推荐(0)

hdu4790 分别在两区间内各取一个数使模p为m的方案
摘要:想到了用容斥简化题目,也想倒如何去算大区间的方案,最后对两个遗留串处理纠结了太久!!帅bin ac后我看了别人题解,真的只是细节讨论那儿处理的失误TAT哎自己傻逼又没写出来! 1 #include 2 #include 3 #include 4 using namespace std; 5 #def... 阅读全文

posted @ 2014-11-07 01:16 xiao_xin 阅读(117) 评论(0) 推荐(0)

hdu1452 积性函数(+逆元,快速幂)
摘要:积性函数定义: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互质数的数目)此题满足第二个,即可拆分成几个素数,然后用等比数... 阅读全文

posted @ 2014-11-06 16:16 xiao_xin 阅读(193) 评论(0) 推荐(0)

hdu1299
摘要: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.... 阅读全文

posted @ 2014-07-16 14:29 xiao_xin 阅读(239) 评论(0) 推荐(0)

hdu2534
摘要: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;... 阅读全文

posted @ 2014-07-16 14:28 xiao_xin 阅读(76) 评论(0) 推荐(0)

导航