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 Submission(s): 736 Accepted Submission(s): 539
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<stdio.h>
#include<string.h>
#include<cstdio>
#include<string>
#include<math.h>
#include<algorithm>
#define LL long long
#define PI atan(1.0)*4
#define DD double
#define MAX 3000010
#define mod 100
#define dian 1.000000011
#define INF 0x3f3f3f
using namespace std;
int main()
{
LL n,m,j,i,k,sum,Max,Min;
int t;
scanf("%d",&t);
while(t--)
{
//printf("1\n");
scanf("%lld%lld",&n,&m);
if(n==m)
{
printf("1\n");
continue;
}
int x;
sum=0;k=0;
Min=min(n,m);
Max=max(n,m);
while(Max!=1&&Min!=1)
{
Max-=Min;
k++;
if(Max<Min)
{
x=Max;
Max=Min;
Min=x;
}
if(Max==Min)
break;
}
if(Max==Min)
printf("%lld\n",k+1);
else if(Max!=Min&&Min==1)
{
sum=sum+k+Max;
printf("%lld\n",sum);
}
}
return 0;
}
hdu 5640 King's Cake(BestCoder Round #75)的更多相关文章
- hdu 5640 King's Cake(模拟)
Problem Description It is the king's birthday before the military parade . The ministers prepared ...
- HDU 5806 - NanoApe Loves Sequence Ⅱ (BestCoder Round #86)
若 [i, j] 满足, 则 [i, j+1], [i, j+2]...[i,n]均满足 故设当前区间里个数为size, 对于每个 i ,找到刚满足 size == k 的 [i, j], ans + ...
- HDU 5805 - NanoApe Loves Sequence (BestCoder Round #86)
先找相邻差值的最大,第二大,第三大 删去端点会减少一个值, 删去其余点会减少两个值,新增一个值,所以新增和现存的最大的值比较一下取最大即可 #include <iostream> #inc ...
- hdu 5641 King's Phone(暴力模拟题)
Problem Description In a military parade, the King sees lots of new things, including an Andriod Pho ...
- 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 5063 Operation the Sequence(Bestcoder Round #13)
Operation the Sequence Time Limi ...
- HDU 5640 King's Cake【模拟】
题意: 给定长方形,每次从中切去一个最大的正方形,问最终可以得到多少正方形. 分析: 过程类似求gcd,每次减去最小的边即可. 代码: #include <cstdio> #include ...
- BestCoder Round #75 1001 - King's Cake
Problem Description It is the king's birthday before the military parade . The ministers prepared a ...
随机推荐
- oracle portlist.ini
Enterprise Manager Database Control URL - (orcl) :https://redhat4.7:1158/em [root@redhat4 install]# ...
- Android app Splash页的替代方案
一般的App想要显示公司的log什么的,都会在启动的第一个页面显示,就是SplashActivity. 目前在看到一个替代SplashActivity的方案. 使用SplashActivity的时候, ...
- varchar 保存英文中文区别。
varchar在SQL Server中是采用单字节来存储数据的,中文字符存储到SQL Server中会保存为两个字节,英文字符保存到数据库中,如果字段的类型为varchar,则只会占用一个字节,而如果 ...
- CY7C68013A的一点总结
一. 值得参考的资料:FX2 TechRefManual.USB应用开发宝典. LabVIEW-USB通信简单教程(用于参考生成labview驱动程序).USB设备请求和描述符整理(仅用于理解描述符的 ...
- Android开发性能优化大总结
1. 采用硬件加速,在androidmanifest.xml中application添加android:hardwareAccelerated="true".不过这个需要在and ...
- poj3307
可以证明,每个符合的数都由2,3,5,7相乘得到. 依据猜想:下一个出现的数是由前面某个数乘上这几个数之一得到的新的数. 假设之前的数均满足序列,则因为下一个数必有2,3,5,7相乘得到,而这个数之前 ...
- C#将HTML导出Excel
首先这个 不能用ajax 操作,不过 我现在讲的 这个方法和ajax 的效果一样. 你在你需要导出的页面写个方法 function DaoChu () { location.href = " ...
- SQL查看数据库所用用户表数量和使用的空间
SQL Server数据库管理员通常硬盘空间奋斗,不断努力清理“表”,撰写许多查询,发现该表使用的硬盘空间. 本文介绍了如何查询系统表的空间使用情况,帮助数据库管理员识别正在使用最多的空间,以便存档旧 ...
- Web Api 返回参数,实现统一标准化!
string camelCaseObj = JsonConvert.SerializeObject(data, Newtonsoft.Json.Formatting.None, new JsonSer ...
- vs2013编译boost库
打开vs2013>>visual studio tools>>VS2013 x64 本机工具命令提示 cd D:\lib\boost_1_55_0\boost_1_55_0 b ...