Problem : 1014 ( Uniform Generator ) Judge Status : Accepted
RunId : 7742145 Language : C Author : qq1203456195
Code Render Status : Rendered By HDOJ C Code Render Version 0.01 Beta
依题意可知,只要两个数的最大公约数为1就ok了~
1 #include <stdio.h> 2 int gcd(int a,int b) 3 { 4 int t,min,max; 5 min=a<b?a:b; 6 max=a<b?b:a; 7 while (t=max%min,t!=0) 8 { 9 max=min; 10 min=t; 11 } 12 return min; 13 } 14 int main() 15 { 16 int a,b,g; 17 while (~scanf("%d%d",&a,&b)) 18 { 19 g=gcd(a,b); 20 printf("%10d%10d ",a,b); 21 if(g>1) 22 printf("Bad Choice\n\n"); 23 else 24 printf("Good Choice\n\n"); 25 } 26 return 0; 27 }