HDU 5640 King's Cake【模拟】
题意:
给定长方形,每次从中切去一个最大的正方形,问最终可以得到多少正方形。
分析:
过程类似求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【模拟】的更多相关文章
- 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 ...
- HDU 5640 King's Cake
King's Cake Problem Description It is the king's birthday before the military parade . The ministers ...
- 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 ...
- hdu 5640 King's Cake(模拟)
Problem Description It is the king's birthday before the military parade . The ministers prepared ...
- HDU 5641 King's Phone 模拟
King's Phone 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5641 Description In a military parade, ...
- BestCoder Round #75 King's Cake 模拟&&优化 || gcd
King's Cake Accepts: 967 Submissions: 1572 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 6553 ...
- HDU 5640
King's Cake Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total ...
- HDU 4041 Eliminate Witches! (模拟题 ACM ICPC 2011亚洲北京赛区网络赛)
HDU 4041 Eliminate Witches! (模拟题 ACM ICPC 2011 亚洲北京赛区网络赛题目) Eliminate Witches! Time Limit: 2000/1000 ...
- hdu 4454 Stealing a Cake(三分之二)
pid=4454" target="_blank" style="">题目链接:hdu 4454 Stealing a Cake 题目大意:给定 ...
随机推荐
- js类、原型——学习笔记
js 内置有很多类,我们用的,都是从这些类实例化出来的. function Object () {} function Array () {} function String () {} functi ...
- css靠左,靠右
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- BOW-js浏览器对象模型
- 2017-11-29 HTML5样式、链接和表格
HTML5样式.链接和表格HTML5列表<ol> 有序列表<ul> 无序列表<li> 列表项 <dl> 列表<dt> 列表项<dd&g ...
- 最实用解决tomcat startup.bat 一闪而过
1.直接到tomcat 的解压路径中找到log日志,eg:D:\tomcat\apache-tomcat-7.0.73\logs 查看 catalina 这个日志文件,可以清除的定位错误原因:一般可能 ...
- Quartz2D知识点聚合案例
Quartz2D知识点聚合 基本 //画图片 UIImage *image = [UIImage imageNamed:@"阿狸头像"]; [image drawInRect:re ...
- js获取select选中的标签option的值
js中获取方法 var obj = document.getElementByIdx_xx_x(”testSelect”); //定位id var index = obj.selectedInde ...
- org.apache.tomcat.util.net.NioEndpoint,打开的文件过多
错误信息: 27-Mar-2019 04:20:20.430 严重 [http-nio-8100-Acceptor-0] org.apache.tomcat.util.net.NioEndpoint$ ...
- WebService 生成客户端
webservice 生成客户端 wsdl2java -encoding UTF-8 -p com.trm -d D:\happywork -client http://localhost/trm-t ...
- error while loading shared libraries: libclntsh.so.11.1
解决这个问题有两种方法 1.在当前用户下,添加链接库所在路径 LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH; export LD_LIBRARY_ ...