zoukankan      html  css  js  c++  java
  • BestCoder Round #75 1001

    Problem Description
    It is the king's birthday before the military parade . The ministers prepared a rectangle cake of size n×m(1n,m10000) . The king plans to cut the cake himself. But he has a strange habit of cutting cakes. Each time, he will cut the rectangle cake into two pieces, one of which should be a square cake.. Since he loves squares , he will cut the biggest square cake. He will continue to do that until all the pieces are square. Now can you tell him how many pieces he can get when he finishes.
     
    Input
    The first line contains a number T(T1000), the number of the testcases.

    For each testcase, the first line and the only line contains two positive numbers n,m(1n,m10000).
     
    Output
    For each testcase, print a single number as the answer.
     
    Sample Input
    2 2 3 2 5
     
    Sample Output
    3 4 hint: For the first testcase you can divide the into one cake of $2 imes2$ , 2 cakes of $1 imes 1$
     
    Source
     

    切正方形蛋糕,两条边轮流互减

     1 #include <iostream>
     2 #include <cstdio>
     3 using namespace std;
     4 #define LL long long
     5 int m,n,t;
     6 LL ans;
     7 int main(){
     8     scanf("%d",&t);
     9     while(t--){
    10         scanf("%d%d",&m,&n);
    11         ans=0;
    12         while(m>0&&n>0){
    13             if(m>n) swap(m,n);
    14             n-=m;
    15             ans++;
    16         }
    17         cout<<ans<<endl;
    18     }
    19 } 
    我自倾杯,君且随意
  • 相关阅读:
    docker清理无用资源
    为什么不需要在 Docker 容器中运行 sshd
    转载:SQL注入演示demo
    docker方式安装prometheus主控
    promethus监控结构
    oracle的函数
    oracle冷备份后恢复
    oracle的冷备份
    oracle常用
    oracle的系统文件的查询
  • 原文地址:https://www.cnblogs.com/nicetomeetu/p/5270332.html
Copyright © 2011-2022 走看看