King's Cake
Total Submission(s): 1288 Accepted Submission(s): 876
For each testcase, the first line and the only line contains two positive numbers n,m(1≤n,m≤10000) .
2 2 3 2 5
3 4 hint: For the first testcase you can divide the into one cake of $2\times2$ , 2 cakes of $1\times 1$
#include <stdio.h>
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int n,m;
scanf("%d%d",&n,&m);
int count=0;
while(n!=m)
{
if(n>m)
n-=m,count++;
else if(n<m)
m-=n,count++;
}
printf("%d\n",count+1);
}
return 0;
}
492



被折叠的 条评论
为什么被折叠?



