标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 188 Accepted Submission(s): 159
1 #include<cstring> 2 #include<cstdio> 3 #include<map> 4 #include<queue> 5 #include<stack> 6 #include<set> 7 using namespace std; 8 int t; 9 int n,m; 10 int main() 11 { 12 scanf("%d",&t); 13 for(int i=1;i<=t;i++) 14 { 15 scanf("%d %d",&n,&m); 16 int t; 17 int ans=0; 18 int minx=min(n,m); 19 if(n>m) 20 { 21 t=n; 22 n=m; 23 m=t; 24 } 25 while(n!=m) 26 { 27 n=m-minx; 28 m=minx; 29 if(n>m) 30 { 31 t=n; 32 n=m; 33 m=t; 34 } 35 minx=min(n,m); 36 ans++; 37 } 38 printf("%d\n",ans+1); 39 40 } 41 return 0; 42 }
标签:
原文地址:http://www.cnblogs.com/hsd-/p/5271713.html