给定整数N,求1<=x,y<=N且Gcd(x,y)为素数的
数对(x,y)有多少对.
标签:des http io sp div c on amp r
给定整数N,求1<=x,y<=N且Gcd(x,y)为素数的
数对(x,y)有多少对.
一个整数N
如题
hint
对于样例(2,2),(2,4),(3,3),(4,2)
1<=N<=10^7
求gcd(x,y)==prime[k] 對數(1<=x,y<=n)
枚舉質數p,求gcd(x,y)==1, (1<=x,y<=n/p)
設sphi(k)表示gcd(x,y)==1,(1<=x,y<=k),那麼,可以通過幾何法推導出sphi(k)=phi(k)*2+sphi(k-1)
然後此題可解。
标签:des http io sp div c on amp r
原文地址:http://www.cnblogs.com/mhy12345/p/4007281.html