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 题目大意:给定 ...
随机推荐
- 在reset css后两个input之间还是出现默认间隔的问题。
<div class="search_box fl"> <input type="text" class="search_text& ...
- NBA15-16赛季半程有感
2015-2016 新赛季NBA已经开打半程又多了,这半个赛季我们见证了 勇士的三节打卡:骑士的磨合反复:马刺的老骥伏枥: 当然还有窝火的XJBD. 豪哥200W刀签约黄蜂,打出来800W刀的身价,无 ...
- hihocoder1705 座位问题
思路: 使用堆模拟.复习了priority_queue自定义结构体比较函数的用法. 实现: #include <bits/stdc++.h> using namespace std; ty ...
- poj2393 Yogurt factory
思路: 贪心. 实现: #include <iostream> #include <cstdio> #include <algorithm> using names ...
- struts 2.5 There is no Action mapped for namespace [/] and action name [user_find] associated with context path [/struts2_crm].
遇到了这个错误. There is no Action mapped for namespace [/] and action name [user_find] associated with con ...
- [转]在ubuntu上安装chrome浏览器
原文链接: https://www.linuxidc.com/Linux/2013-10/91857.htm --------------------------------------------- ...
- LigerUI用Post\Get\Ajax前后台交互方式的写法
parms 参数统一 json格式的数据 url 访问后台的url 设置同步参数 [javascript] view plain copy $.ajaxSetup({ async : false} ...
- 读取.properties配置信息
package com.ctcti.webcallcenter.utils; import java.io.FileInputStream;import java.io.FileNotFoundExc ...
- C/C++ 运算符重载、数据类型转换
1.运算符就是“+”.“>>”等符号,对运算符重载实质就是对函数的重载,这样运算符就能在原有基础上增加新功能,不能自己定义新运算符,只能对已有运算符重载,重载运算符后不能改变运算符本身的特 ...
- AttributeError: 'tuple' object has no attribute 'extend'
出错demo In [5]: a.extend([4,5]) --------------------------------------------------------------------- ...