Portal
Description of the problem one day, the ACM's Anxiaoqiu got a very big big piece of paper. He is now going to tear it into a square. But he doesn't have any tools, no rulers, so he tries an interesting way to slice the rectangle. Suppose this is a a*b rectangle (a>b), then the little will be a corner of the rectangle fold, so that the right side will form a square, and then cut out the square, if there is still a rectangle, Anxiaoqiu will continue to cut the square out, now ask you to write programs, output Anxiaoqiu so that eventually can How many squares to get.
Input requires more than one set of input data.
Each test data is a row, there are two integers a, b, respectively, represents the length and width of the paper that the 1≤
b<
a≤10^12) output requires output, and the output takes up one row. Test Data Sample Input 2 1
10 7 Output 2
6 Today, I did a new school problem, I think it is quite fun. There are some geometrical problems that need to be optimized, and the violence will be tle. First, if B is a factor, that is, A%b ==0, then, it is not difficult to think, you can know the number of squares generated in the current situation A/b. So when a%b!=0, that means to lose a part of the square, and then Judge A%b==0, It's OK. On the Code
#include <stdio.h>Long LongSlove (Long LongALong Longb) { Long LongRET =0; while(a!=b) { if(a<b) { intt =b; b=FA; A=T; } if(a%b==0){ returnRet+ (A/b); }Else{ret+=a/b; A=a-(b* (A/b)); } } if(a==b) ret++; returnret;}intMain () {Long Longb; while(SCANF ("%lld%lld", &a,&b) = =2) {printf ("%lld\n", Slove (A, b)); } return 0;}
[Bnuz oj]1176 and Square