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 题目大意:给定 ...
随机推荐
- BOW-js浏览器对象模型
- mysql 判断字符串是否为其他字符串的子集
1.mysql 提供单个用逗号隔开判断某个字符串是否包含在其他字符串的之内:FIND_IN_SET('需要匹配的字符串','源字符串'); demo: select FIND_IN_SET('111' ...
- springmvc系列一 之配置介绍(包含官网doc)
1.springmvc 官网参考地址: https://docs.spring.io/spring/docs/current/spring-framework-reference/web.html 2 ...
- [备忘]Notification的实用
Intent resultIntent = null; if (!TextUtils.isEmpty(tid)){ resultIntent = new Intent("com.shijie ...
- VUE 入坑系列 一 双向绑定
html代码 <div id="app"> <p>{{message}}</p> <span>message1</span&g ...
- JVM最多能创建多少个线程: unable to create new native thread
转载自:http://www.rigongyizu.com/jvm-max-threads/ 有应用报出这样的异常“java.lang.OutOfMemoryError: unable to crea ...
- leetcode_1015. Numbers With Repeated Digits
https://leetcode.com/problems/numbers-with-repeated-digits/ 与leetcode_357. Count Numbers with Unique ...
- Java泛型中的协变和逆变
Java泛型中的协变和逆变 一般我们看Java泛型好像是不支持协变或逆变的,比如前面提到的List<Object>和List<String>之间是不可变的.但当我们在Java泛 ...
- Python游戏开发入门
Pygame简介与安装 1.Pygame安装 pip install pygame2.检测pygame是否安装成功 python -m pygame.examples.aliens Pygame最小开 ...
- boostrapvalidator
一个例子 <%@ page contentType="text/html;charset=UTF-8" language="java" %> < ...