-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1577.cpp
72 lines (62 loc) · 1.17 KB
/
1577.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include <iostream.h>
int gcd(int a,int b)
{
if(a%b==0)
return b;
else
return gcd(b,a%b);
}
void main ()
{
int a,b,res,x,y,n,t,p,q;
while (cin>>x>>y)
{
if (y%x) {cout<<"0"<<endl;continue;}
if (x==y) {cout<<"1"<<endl;continue;}
n=0;
for (a=x;a<=y;a+=x)
{
if (y%a) continue;
p=a;
q=x*y/p;b=q;
if (p>q) break;//cout<<"("<<p<<","<<q<<")=";
res=gcd(p,q);
//cout<<res<<endl;
if (res==x&&a*b/x==y) n++;
}
cout<<n*2<<endl;
}
}
/*
#include <stdio.h>
int gcd(int a,int b)
{
if(a%b==0)
return b;
else
return gcd(b,a%b);
}
int main( void ){
int x0,y0,i,count,j;
while( scanf( "%d%d",&x0,&y0 )!=EOF ){
count = 0;
if( (y0%x0) )
printf( "0\n" );
else if( x0==y0 )
printf( "1\n" );
else{
for( i=x0;i<=y0;i+=x0 ){
if( (x0%i) && (y0%i) )
continue;
j = (y0/i)*x0;
if( j<i )
break;
if( gcd( j,i )==x0 )
count++;
}
printf( "%d\n",count*2 );
}
}
return 0;
}
*/