HDU 5640
King's Cake
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 188 Accepted Submission(s): 159
For each testcase, the first line and the only line contains two positive numbers n,m(1≤n,m≤10000).
For the first testcase you can divide the into one cake of $2\times2$ , 2 cakes of $1\times 1$
#include<cstring>
#include<cstdio>
#include<map>
#include<queue>
#include<stack>
#include<set>
using namespace std;
int t;
int n,m;
int main()
{
scanf("%d",&t);
for(int i=;i<=t;i++)
{
scanf("%d %d",&n,&m);
int t;
int ans=;
int minx=min(n,m);
if(n>m)
{
t=n;
n=m;
m=t;
}
while(n!=m)
{
n=m-minx;
m=minx;
if(n>m)
{
t=n;
n=m;
m=t;
}
minx=min(n,m);
ans++;
}
printf("%d\n",ans+); }
return ;
}
HDU 5640的更多相关文章
- 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 5640 King's Cake【模拟】
题意: 给定长方形,每次从中切去一个最大的正方形,问最终可以得到多少正方形. 分析: 过程类似求gcd,每次减去最小的边即可. 代码: #include <cstdio> #include ...
- Hdu 5036-Explosion 传递闭包,bitset,期望/概率
题目:http://acm.hdu.edu.cn/showproblem.php?pid=5036 Explosion Time Limit: 6000/3000 MS (Java/Others) ...
- hdu 2825 aC自动机+状压dp
Wireless Password Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others ...
- HDOJ 2111. Saving HDU 贪心 结构体排序
Saving HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- 【HDU 3037】Saving Beans Lucas定理模板
http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...
随机推荐
- Java 输出对象为字符串 工具类
public static String reflectionToString(Object o){ if(o == null) return StringUtils.EMPTY; StringBui ...
- 【WXS全局对象】Number
属性: 名称 说明 Number.MAX_VALUE 返回JS中可表示的最大的数.它的近似值为 1.7976931348623157 x 10308. Number.MIN_VALUE 返回JS中可表 ...
- 【hidden】微信小程序hidden属性使用示例
hidden属性用于隐藏标签,代码示例: <view hidden="{{!statusTag}}">我出来了~</view> <button bin ...
- python中的迭代器与生成器
迭代器 迭代器的引入 假如我现在有一个列表l=['a','b','c','d','e'],我想取列表中的内容,那么有几种方式? 1.通过索引取值 ,如了l[0],l[1] 2.通过for循环取值 fo ...
- Java学习 · 初识 面向对象深入二
面向对象深入 1. 抽象类 a) 声明 i. 抽象方法和抽象类必须用abstract来修饰 ii. 没有方法体,不需要实现 b) ...
- 在页面使用echarts的地图(解决地图不完整)
测试环境:IDEA+Tomcat7 谷歌浏览器 创建好web工程,编写jsp页面,在自己编写的JSP页面上导包 现在echarts停止了在其网站上下载地图脚本,直接通过src引用网站上的china.j ...
- 【第四章】Shell 条件测试表达式
shell中条件测试的三种格式: 格式1: test 条件表达式格式2: [ 条件表达式 ]格式3: [[ 条件表达式 ]] 使用test: [root@host- ~]# test -f file ...
- 从零开始的Python学习Episode 6——字符串操作
字符串操作 一.输出重复字符串 print('smile'*6) #输出6个smile 二.通过引索输出部分字符串 print('smile'[1:]) print('smile'[1:3]) #输出 ...
- Python 学习笔记之——用 sklearn 对数据进行预处理
1. 标准化 标准化是为了让数据服从一个零均值和单位方差的标准正态分布.也即针对一个均值为 \(mean\) 标准差为 \(std\) 的向量 \(X\) 中的每个值 \(x\),有 \(x_{sca ...
- Oil Deposits(DFS连通图)
Description The GeoSurvComp geologic survey company is responsible for detecting underground oil dep ...