Codeforces Round #296 (Div. 2) -----A. Playing with Paper
来源:互联网 发布:淘宝粉丝怎么看 编辑:程序博客网 时间:2024/06/12 18:48
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.
#include<iostream> using namespace std; int main(){
long long a,b,ans; ans=0; cin>>a>>b; for(;;) { if(a>b) { ans+=a/b; a=a%b; } else { ans+=b/a; b=b%a; } if(a<=0||b<=0) break; } cout<<ans; return 0;}
- Codeforces Round #296 (Div. 2) A. Playing with Paper
- Codeforces Round #296 (Div. 2) -----A. Playing with Paper
- A. Playing with Paper( Codeforces Round #296 (Div. 2) 水题)
- Codeforces Round #222 (Div. 2)---A. Playing with Dice
- Codeforces 527A Playing with Paper
- CodeForces 527A Playing with Paper
- codeforces 527A Playing with Paper
- A. Playing with Paper
- A. Playing with Paper
- A-Playing with Paper
- A-Playing with Paper
- CodeForces 527A Playing with Paper 折纸游戏
- 527A. Playing with Paper
- 527A. Playing with Paper
- 527A. Playing with Paper【math】
- Codeforces Round #133 (Div. 2) A. Tiling with Hexagons(数学)
- Codeforces Round #258 (Div. 2)1A Game With Sticks
- Codeforces Round #258 (Div. 2/A)/Codeforces451A_Game With Sticks
- Java中ArrayList与LinkedList的区别
- 华为2015实习上机:字符串排序
- pomelo chatroom
- Git学习笔记(二)---简单的使用
- Linux程序设计(Linux shell编程的例子:获取文件列表)
- Codeforces Round #296 (Div. 2) -----A. Playing with Paper
- 算法导论—哈希
- extra qualification ‘Matrix::’ on member ‘rowTimesCol’
- 黑马程序员_学习笔记泛型
- IntelliJ idea创建spring mvc项目
- 常用的正则表达式
- 排序算法整理(一)
- 什么行业最有前途 教你如何在IT业拿高薪!
- 两种不同的方法来实现一个两列布局