CF527A Playing with Paper
来源:互联网 发布:马尔科夫转移概率知乎 编辑:程序博客网 时间:2024/06/05 08:09
One day Vasya was sitting on a not so interesting Maths lesson and making an origami from a rectangular a mm × b mm sheet of paper (a > b). Usually the first step in making an origami is making a square piece of paper from the rectangular sheet by folding the sheet along the bisector of the right angle, and cutting the excess part.
After making a paper ship from the square piece, Vasya looked on the remaining (a - b) mm × b mm strip of paper. He got the idea to use this strip of paper in the same way to make an origami, and then use the remainder (if it exists) and so on. At the moment when he is left with a square piece of paper, he will make the last ship from it and stop.
Can you determine how many ships Vasya will make during the lesson?
The first line of the input contains two integers a, b (1 ≤ b < a ≤ 1012) — the sizes of the original sheet of paper.
Print a single integer — the number of ships that Vasya will make.
2 1
2
10 7
6
1000000000000 1
1000000000000
Pictures to the first and second sample test.
//简单题 但是简单一步步模拟会超时,加入gcd即可
#include <iostream>#include <cstdio>#include <cstring>#include <string>#include <algorithm>using namespace std;long long max(long long a,long long b){if(a > b) return a;else return b;}long long min(long long a,long long b){if(a < b) return a;else return b; }int main(){long long a,b;cin >> a >> b;long long cnt = 0;while(a && b){cnt += a/b;long long temp = a%b;a -= a/b*b;a = max(a,b);b = min(temp,b);}cout << cnt << endl;}
- CF527A Playing with Paper
- A. Playing with Paper
- A. Playing with Paper
- Playing with Paper
- A-Playing with Paper
- A-Playing with Paper
- 527A. Playing with Paper
- D-codeforces527A- Playing with Paper
- 527A. Playing with Paper
- Codeforces 527A Playing with Paper
- 527A. Playing with Paper【math】
- CodeForces 527A Playing with Paper
- codeforces 527A Playing with Paper
- Codeforces Round #296 (Div. 2) A. Playing with Paper
- Codeforces Round #296 (Div. 2) -----A. Playing with Paper
- CodeForces 527A Playing with Paper 折纸游戏
- Paper Reading 1 - Playing Atari with Deep Reinforcement Learning
- A. Playing with Paper( Codeforces Round #296 (Div. 2) 水题)
- Android 完美高仿的微信源码
- 陈怡暖:2015.5.12早间现货黄金白银操作建议
- Java多线程
- 思考:【滤镜仅在IE有效!】在style使用filter(滤镜)设置水平翻转(flipH)和竖直翻转(flipV)
- 【C/C++学习】const用法总结
- CF527A Playing with Paper
- Java自定义模板设计
- mysql 查看排序集
- 机器学习领域的几种主要学习方式
- VARCHART XGantt经典案例:Apper的芬兰公共交通系统
- 【Android】【Theme】Activity 全屏,透明
- 指针
- aac 文件数据帧读取分析
- 类string运算符的重载