A-Playing with Paper
来源:互联网 发布:php的魔术方法 编辑:程序博客网 时间:2024/05/29 18:37
Description
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?
Input
The first line of the input contains two integers a, b (1 ≤ b < a ≤ 1012) — the sizes of the original sheet of paper.
Output
Print a single integer — the number of ships that Vasya will make.
Sample Input
2 1
2
10 7
6
1000000000000 1
1000000000000
Hint
Pictures to the first and second sample test.
题目大意:给一个长方形,看能折出多少个正方形。
题目链接:http://codeforces.com/problemset/problem/527/A
源代码:
#include<cstdio>#include<iostream>#include<algorithm>#include<vector>#include<stack>#include<stdlib.h>#include<set>#include<cstring>#include<queue>using namespace std;__int64 ans=0;int main(){ __int64 a,b; scanf("%I64d%I64d",&a,&b); while(a != b) { if(a<b) { __int64 t = a; a = b; b = t; } __int64 p; p = a / b; ans += p; a = a - b*p; if(a == 0) { break; } if(p == 0) { ans++; } } printf("%I64d\n",ans); return 0;}
- A. Playing with Paper
- A. Playing with Paper
- A-Playing with Paper
- A-Playing with Paper
- 527A. 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
- Playing with Paper
- CF527A 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 折纸游戏
- D-codeforces527A- Playing with Paper
- A. Playing with Dice
- A. Playing with Paper( Codeforces Round #296 (Div. 2) 水题)
- 启动ambari-server报错
- 【大话设计模式】工厂三姐妹
- Android app 运行时按了Home键,进入到另一程序,再调用原来程序
- PHP扩展函数返回字符串一定需要使用spprintf吗?
- git 中fetch+rebase工作流
- A-Playing with Paper
- Memory Analysis for Android Applications
- 正则表达式实战
- Android 中tomcat搭建本地服务器 实现apk更新下载
- iOS 纯代码适配iPhone6,6p
- java文本编辑器插件kinderditor用法解决本地图片上传不能用
- KM算法求带权二分图的最大匹配(完备匹配)
- LocalBroadcastManager 使用小结
- RxJava 详解