【题目链接】:http://codeforces.com/contest/527/problem/A

【题意】



让你每次从一个长方形里面截出一个边长为长方形的较短边的正方形;

然后留下的部分重复上述步骤;

直到剩下的部分为正方形为止;

问你一共截出了多少个正方形

【题解】



写个递归求解就好;

每次短边的边长不变;

然后答案递增长边长度/短边长度

长边的边长变为长边%短边->为0的话就改为短边长度,下一次递归结束就好;



【完整代码】

#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define ps push_back
#define fi first
#define se second
#define rei(x) scanf("%d",&x)
#define rel(x) scanf("%lld",&x)
#define ref(x) scanf("%lf",&x) typedef pair<int, int> pii;
typedef pair<LL, LL> pll; const int dx[9] = { 0,1,-1,0,0,-1,-1,1,1 };
const int dy[9] = { 0,0,0,-1,1,-1,1,-1,1 };
const double pi = acos(-1.0);
const int N = 110; LL a, b,ans = 0; void dfs(LL a, LL b)
{
//a>b
if (a == b)
{
ans++;
return;
}
LL t = a / b;
a = a%b;
if (a == 0)
{
a = b;
t--;
}
ans += t;
dfs(b, a);
} int main()
{
//freopen("F:\\rush.txt", "r", stdin);
rel(a), rel(b);
dfs(max(a,b),min(a, b));
printf("%lld\n", ans);
//printf("\n%.2lf sec \n", (double)clock() / CLOCKS_PER_SEC);
return 0;
}

【codeforces 527A】Playing with Paper的更多相关文章

  1. 【codeforces 415D】Mashmokh and ACM(普通dp)

    [codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...

  2. 【codeforces 755B】PolandBall and Game

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  3. 【codeforces 754B】 Ilya and tic-tac-toe game

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  4. 【codeforces 546D】Soldier and Number Game

    time limit per test3 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  5. 【codeforces 546C】Soldier and Cards

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  6. 【13.77%】【codeforces 734C】Anton and Making Potions

    time limit per test4 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  7. 【32.89%】【codeforces 574D】Bear and Blocks

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  8. 【26.67%】【codeforces 596C】Wilbur and Points

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  9. 【22.73%】【codeforces 606D】Lazy Student

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

随机推荐

  1. How to: Specify the Web Server for Web Projects in Visual Studio

    https://msdn.microsoft.com/en-us/library/ms178108(v=vs.120).aspx When you run a Web project in Visua ...

  2. 2.EF的数据审计日志

    转载:采用EntityFramework.Extended 对EF进行扩展(Entity Framework 延伸系列2) 数据审计日志: 先说一下这个审计的概念,就是对所有的实体的操作(增,删,改) ...

  3. hdu 4587(枚举+割顶)

    TWO NODES Time Limit: 24000/12000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total ...

  4. Emoji过滤

    private static boolean isNotEmojiCharacter(char codePoint) { return (codePoint == 0x0) || (codePoint ...

  5. C# 接口命名规范

    接口命名规范:1.大写约定PascalCasing:帕斯卡命名法,每个单词首字母大写应用场景:命名空间.类型.接口.方法.属性.事件.字段.枚举.枚举值eg:HtmlTag IOStream注意:两个 ...

  6. Unity学习-鼠标的常用操作(八)

    本次主要介绍5个鼠标事件 void OnMouseEnter():鼠标进入 void OnMouseExit():鼠标移出 void OnMouseDown():鼠标点击 void OnMouseUp ...

  7. <form> 标签

    <form method="传送方式" action="服务器文件"> action :浏览者输入的数据被传送到的地方,比如一个PHP页面(save ...

  8. Android 自己搭建一个直播系统吧

    服务端用 SRS(Simple Rtmp Server),在这里下载simple-rtmp-server需要Linux系统最好是Ubuntu,装个Ubuntu虚拟机就行了在Linux里,解压缩SRS ...

  9. Intent的调用

    //Intent  intent=new Intent();//intent.setClass(MainActivity.this, GPSService.class);//以上二条可以合并成如下一条 ...

  10. iOS CoreData 开发之数据模型关系

    接着上一篇,上一篇中,我们简单的实现了一个用户实体,本次添加一个用户信息实体,与用户实体相关联,关系为1:1. 新建一个实体UserInfo: