题意:

给定长方形,每次从中切去一个最大的正方形,问最终可以得到多少正方形。

分析:

过程类似求gcd,每次减去最小的边即可。

代码:

#include <cstdio>
#include<algorithm>
#include<iostream>
using namespace std;
int main (void)
{
int T;cin>>T;
int n, m;
while(T--){
cin>>n>>m;
int cnt = 0;
int t;
while(n!=m && n && m){
cnt++;
if(m<n) n -= m;
else m-=n;
}
cout<<cnt+1<<endl;
}
}

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 5641 King's Phone 模拟

    King's Phone 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5641 Description In a military parade, ...

  6. BestCoder Round #75 King&#39;s Cake 模拟&amp;&amp;优化 || gcd

    King's Cake Accepts: 967 Submissions: 1572 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 6553 ...

  7. HDU 5640

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

  8. HDU 4041 Eliminate Witches! (模拟题 ACM ICPC 2011亚洲北京赛区网络赛)

    HDU 4041 Eliminate Witches! (模拟题 ACM ICPC 2011 亚洲北京赛区网络赛题目) Eliminate Witches! Time Limit: 2000/1000 ...

  9. hdu 4454 Stealing a Cake(三分之二)

    pid=4454" target="_blank" style="">题目链接:hdu 4454 Stealing a Cake 题目大意:给定 ...

随机推荐

  1. Dev之GridControl详解

    Dev控件中的表格控件GridControl控件非常强大.不过,一些细枝末节的地方有时候用起来不好找挺讨厌的.使用过程中,多半借助Demo和英文帮助文档.网上具体的使用方法也多半零碎.偶遇一个简单而且 ...

  2. CF949B A Leapfrog in the Array

    思路: 最终的时候,对于位置p,若p是奇数,则该位置的元素是(p + 1) / 2:若p是偶数,需要从p开始不断地迭代寻找上一次跳跃所处的位置(p = p + n - p / 2),直到p是奇数为止. ...

  3. [BZOJ2005][NOI2010]能量采集 数学

    题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=2005 发现与$(0,0)$连线斜率相同的点会被挡住.也就是对于$(a,b)$且$gcd(a ...

  4. MySQL性能优化之max_connections配置

    MySQL的最大连接数,增加该值增加mysqld 要求的文件描述符的数量.如果服务器的并发连接请求量比较大,建议调高此值,以增加并行连接数量,当然这建立在机器能支撑的情况下,因为如果连接数越多,介于M ...

  5. Beta测试团队

    ---恢复内容开始--- Beta版本测试 这个作业属于哪个课程 https://edu.cnblogs.com/campus/xnsy/SoftwareEngineeringClass1/?page ...

  6. 面包屑 asp代码记录 newsmulu_class 内部函数

    'id 这里其实是 classId 'mbStr1 最右边的栏目模板 由于是当前本页面 就不带链接了 建议默认值:<span class='mbxC'>$title</span> ...

  7. 第2节 mapreduce深入学习:8、手机流量汇总求和

    第2节 mapreduce深入学习:8.手机流量汇总求和 例子:MapReduce综合练习之上网流量统计. 数据格式参见资料夹 需求一:统计求和 统计每个手机号的上行流量总和,下行流量总和,上行总流量 ...

  8. SQL SERVER系统表和常用函数介绍

    sysaltfiles 主数据库 保存数据库的文件 syscharsets 主数据库 字符集与排序顺序sysconfigures 主数据库 配置选项syscurconfigs 主数据库 当前配置选项s ...

  9. CSS工具、CSS重置(CSS Reset)

    样式重置的目的是减少浏览器的不一致性,例如line-height,margin,标题的font-size大小等等.样式重置经常在CSS框架中出现. 这里的重置样式故意写的很一般,例如没有为body元素 ...

  10. Go:工厂模式

    Go的结构体没有构造函数,通常可以使用工厂模式来解决这个问题. 一个结构体的声明是这样的: package model type Student struct { Name string } 因为 S ...