Enter two positive integers to obtain the maximum number of common integers.
-
Question 1056: Maximum number of common appointments
-
Time Limit: 1 second
Memory limit: 32 MB
Special question: No
Submit: 4771
Solution: 3097
-
Description:
-
Enter two positive integers to obtain the maximum number of common integers.
-
Input:
-
There are multiple groups of test data. Each group has two positive integers.
-
Output:
-
For each group of input, please output its maximum public approx.
-
Sample input:
-
49 14
-
Sample output:
-
7
-
#include
int x(int a,int b){ if(a%b==0)return b; else return x(b,a%b);}int main(int argc, char *argv[]){ int m,n; // freopen("in.txt","in",stdin); while(scanf("%d %d",&m,&n)!=EOF) { if(m>n) printf("%d\n",x(m,n)); else printf("%d\n",x(n,m)); } return 0;} /************************************************************** Problem: 1056 User: kirchhoff Language: C Result: Accepted Time:0 ms Memory:912 kb****************************************************************/