标签:des style blog http color io os ar java
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)
Total Submission(s): 1092 Accepted Submission(s): 512
题意:求满足 gcd(x,y,z) = g , lcm(x,y,z) = l 的 组数
首先 l%g != 0 肯定是不行的,
我们对 l 和 g 经行素数分解
g = p1^a1 * p2 ^ a2 * p3 ^ a3 ...
l = p1^b1 * p2 ^ b2 * p3 ^ b3 ...
#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<cmath> #include<queue> #include<vector> #include<set> #include<stack> #include<map> #include<ctime> #include<bitset> #define LL long long #define mod 1000000007 #define maxn 110 #define pi acos(-1.0) #define eps 1e-8 #define INF 0x3f3f3f3f using namespace std; bool check(LL i ) { for(int j = 2 ; j*j <= i ;j++)if(i%j == 0) return false; return true; } int main() { int j,i,l,g; int T,ans1,u,v; LL ans; cin >> T ; while(T--) { scanf("%d%d",&g,&l ) ; if(l%g !=0)puts("0") ; else { l /= g ; ans=1; for( LL i = 2 ; i*i <= l ;i++)if(l%i==0&&check(i)) { v = 0; while(l%i==0) { v++; l /= i ; } ans *= v*6 ; } if(l !=1) ans *= 6 ; printf("%I64d\n",ans); } } return 0 ; }
标签:des style blog http color io os ar java
原文地址:http://www.cnblogs.com/20120125llcai/p/4027693.html