题目链接

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. 【Atheros】网卡驱动速率调整算法概述

    我做网卡驱动,最主要的内容就是设计和改进速率调整算法,随着802.11协议簇的新标准越来越多,速率越来越高,调制编码方式也越来越多,一般来说,速率越高越可能丢包,速率越低越稳定,这是整体状况,但不是必 ...

  2. STM32 Option Bytes位 重置为出厂设置

    STM32 Option Bytes位 重置为出厂设置 JLINK 按照说明,在IAR安装目录下找到指定的运行程序JLinkSTM32.exe(D:\Program Files (x86)\IAR S ...

  3. WPF中的数据模板使用方式之一:ContentControl、ContentTemplate和TemplateSelector的使用

    在WPF中,数据模板是非常强大的工具,他是一块定义如何显示绑定的对象的XAML标记.有两种类型的控件支持数据模板:(1)内容控件通过ContentTemplate属性支持数据模板:(2)列表控件通过I ...

  4. Linux时间时区详解与常用时间函数

    时间与时区 整个地球分为二十四时区,每个时区都有自己的本地时间. Ø  UTC时间 与 GMT时间 我们可以认为格林威治时间就是时间协调时间(GMT = UTC),格林威治时间和UTC时间都用秒数来计 ...

  5. swift中的?和!理解

    本文转载至 http://www.cnblogs.com/dugulong/p/3770367.html 首先贴cocoachina上某位大大的帖子:     Swift语言使用var定义变量,但和别 ...

  6. 【BZOJ3926】[Zjoi2015]诸神眷顾的幻想乡 广义后缀自动机

    [BZOJ3926][Zjoi2015]诸神眷顾的幻想乡 Description 幽香是全幻想乡里最受人欢迎的萌妹子,这天,是幽香的2600岁生日,无数幽香的粉丝到了幽香家门前的太阳花田上来为幽香庆祝 ...

  7. openssl将私钥和crt证书合成pfx证书

    pfx是什么文件:公钥加密技术12号标准(Public Key Cryptography Standards #12,PKCS#12)为存储和传输用户或服务器私钥.公钥和证书指定了一个可移植的格式.它 ...

  8. windowsphone8.1学习笔记之应用数据(四)

    应用数据的存储格式常用的分为json和xml两种(其实我都想略过这个地方的,json我一直用的是json.net,而wp上操作xml的方式与其他相比也没太多变化). 先说说json数据存储,关于jso ...

  9. java的小知识点

    1 获取当前路径 System.getProperty("user.dir") System.getProperty()参数大全# java.version            ...

  10. PhotoKit详解

    Photokit介绍 这篇主要介绍如何通过 Photokit获取数据 photokit.jpg 1,基类 PHObject Photos 框架中的根类PHObject只有一个公开接口 localIde ...