标签:others new http include text enter panel 最大公约数 its
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 18480 Accepted Submission(s): 7708
1 #include <bits/stdc++.h> 2 using namespace std; 3 int gcd(int x,int y) 4 { 5 return y==0?x:gcd(y,x%y); 6 } 7 int main() 8 { 9 int n; 10 while(scanf("%d",&n)!=EOF) 11 { 12 while(n--) 13 { 14 int a,b; 15 scanf("%d%d",&a,&b); 16 for(int i=b;;i++) 17 { 18 if(gcd(i,a)==b&&i!=b&&gcd(i,b)==b) 19 { 20 printf("%d\n",i); 21 break; 22 } 23 } 24 } 25 } 26 return 0; 27 }
HDU 2504 又见GCD(最大公约数与最小公倍数变形题)
标签:others new http include text enter panel 最大公约数 its
原文地址:http://www.cnblogs.com/ECJTUACM-873284962/p/6675925.html