题目链接

King's Cake

Time Limit: 2000/1000 MS (Java/Others)    

Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 79    Accepted Submission(s): 69

Problem Description
It is the king's birthday before the military parade . The ministers prepared a rectangle cake of size n×m(1≤n,m≤10000) . 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(T≤1000), the number of the testcases.

For each testcase, the first line and the only line contains two positive numbers n,m(1≤n,m≤10000).

 
Output
For each testcase, print a single number as the answer.
 
Sample Input
2
2 3
2 5
 
Sample Output
3
4
AC代码:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int n,m;
scanf("%d%d",&n,&m);
int ans=,mmin,mmax;
while(n&&m)
{
if(n>m)
{
n-=m;
}
else
{
m-=n;
}
ans++;
}
cout<<ans<<"\n"; }
return ;
}

hdu-5640 King's Cake (水题)的更多相关文章

  1. HDU 5640 King's Cake GCD

    King's Cake 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5640 Description It is the king's birthd ...

  2. HDU 5640 King's Cake

    King's Cake Problem Description It is the king's birthday before the military parade . The ministers ...

  3. hdu 5640 King's Cake(BestCoder Round #75)

    King's Cake Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total ...

  4. hdu 5640 King's Cake(模拟)

    Problem Description   It is the king's birthday before the military parade . The ministers prepared ...

  5. HDU 5640 King's Cake【模拟】

    题意: 给定长方形,每次从中切去一个最大的正方形,问最终可以得到多少正方形. 分析: 过程类似求gcd,每次减去最小的边即可. 代码: #include <cstdio> #include ...

  6. HDU 5578 Friendship of Frog 水题

    Friendship of Frog Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.ph ...

  7. HDU 5590 ZYB's Biology 水题

    ZYB's Biology Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid ...

  8. HDU 5538 L - House Building 水题

    L - House Building Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.ph ...

  9. Codeforces Round #343 (Div. 2) A. Far Relative’s Birthday Cake 水题

    A. Far Relative's Birthday Cake 题目连接: http://www.codeforces.com/contest/629/problem/A Description Do ...

随机推荐

  1. 嵌入式开发之字符叠加---gb2313 国标码,utf8 国际码,unicode 无码

    (1)国标码简介 (2)编码转换 (3)时间获取 (4)显示切换 最近做了个字符叠加,包括时间叠加,字符中文叠加,位置移动,等功能开启.因为一般的字符叠加的点阵式16位,然后填充着16位的编码是gb2 ...

  2. html5小趣味知识点系列(一)spellcheck

    发现一些h5的系ode知识点增加一些趣味性 实用性 不敢妄自评论  觉得有用就用一下  没用就路过一下 spellcheck属性 它的功能是针对用户输入的文本内容进行拼写和语法检查 用于input 和 ...

  3. scp命令需要指定端口时要紧跟在scp后

      问题来源:我本地是Ubuntu操作系统,有时需要更新一些文件到服务器.但是,为了安全起见我们都是将服务器的sshd端口修改的,通常不使用默认的22号端口. 如果我们使用scp命令时:scp upl ...

  4. 几种动态调用js函数方案的性能比较

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  5. nginx服务器的内核调优

    TCP公有类 net.core.somaxconn = 262144 net.core.netdev_max_backlog = 262144 net.ipv4.ip_local_port_range ...

  6. csv .xlsx

    def gen_file_data(fodir, fname, sheet_index=0, ): if fname.find('.xlsx') > -1: fname_open = '%s\\ ...

  7. LookAndFeelInfo

    在读zap源码的时候碰到:UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());以下来自百度知道UIManager.s ...

  8. Linux内核设计基础(九)之进程管理和调度

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/BlueCloudMatrix/article/details/30799225 在Linux中进程用 ...

  9. 好用的 curl 抓取 页面的封装函数

    由于经常使用php curl 抓取页面的内容,在此mark 平时自己封装的 curl函数,(其实 现在也开始用 Python 来爬了~ ^-^) /** * 封装curl方法 * @author Fr ...

  10. jquery中篇

    一.attr 返回属性值 返回被选元素的属性值. 语法 $(selector).attr(attribute) 参数 描述 attribute 规定要获取其值的属性. 属性 • 属性 o attr(n ...