【题目链接】: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. bzoj 2465 小球

    题目大意: 给定n个不同颜色的球,每个球都有一个分数,同时有m个瓶子,每个瓶子都有固定的容量 必须把球放到瓶子里面 计算最多能放多少个球到这些瓶子里 思路: 开始想的是费用流 超级源向每个球连一条 容 ...

  2. hebernate基础学习2---属性

    ---------------------------------------------------------------------------------------------------- ...

  3. [Swift通天遁地]三、手势与图表-(3)通过捏合手势放大和缩小图像视图

    ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★➤微信公众号:山青咏芝(shanqingyongzhi)➤博客园地址:山青咏芝(https://www.cnblogs. ...

  4. $P2935 [USACO09JAN]最好的地方Best Spot$

    P2935 [USACO09JAN]最好的地方Best Spot Floyd的水题(黄题) 海星. 这可能是我第一道发的Floyd的博客 inline void Floyd(){ ;k<=n;k ...

  5. Elasticsearch之CURL命令的DSL查询

    它是Domain Specific Language领域特定语言. https://www.elastic.co/guide/en/elasticsearch/reference/current/in ...

  6. RabbitMQ~消息的产生和管理(15672)

    上一讲说了rabbitmq在windows环境的部署,而今天主要说一下消息在产生后,如何去查看消息,事实上,rabbitmq为我们提供了功能强大的管理插件,我们只要开启这个插件即可,它也是一个网站,端 ...

  7. MySQL索引----数据结构及算法原理

    摘要 本文以MySQL数据库为研究对象,讨论与数据库索引相关的一些话题.特别需要说明的是,MySQL支持诸多存储引擎,而各种存储引擎对索引的支持也各不相同,因此MySQL数据库支持多种索引类型,如BT ...

  8. [转]STL之deque容器详解

    Deque 容器 deque容器是C++标准模版库(STL,Standard Template Library)中的部分内容.deque容器类与vector类似,支持随机访问和快速插入删除,它在容器中 ...

  9. 关于类似vue-cli 脚手架

    #!/usr/bin/env node const download = require('download-git-repo') const program = require('commander ...

  10. html5——多媒体(一)

    <audio> 1.autoplay 自动播放 2.controls 是否显不默认播放控件 3.loop 循环播放 4.preload 预加载 同时设置autoplay时些属性失效 5.由 ...