Playing with Paper

time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

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 test(s)
Input
2 1
Output
2
Input
10 7
Output
6
Input
1000000000000 1
Output
1000000000000

 #include <iostream>
#include <cstdio>
using namespace std; int main(void)
{
long long count;
long long a,b; while(scanf("%lld%lld",&a,&b) != EOF)
{
count = ;
if(!(a % b))
{
cout << a / b << endl;
continue;
} int flag = ; while((a % b))
{
count += a / b;
a %= b;
if(a < b)
swap(a,b);
if(a % b == )
count += a / b;
}
cout << count << endl;
} return ;
}

CF Playing with Paper的更多相关文章

  1. Codeforces Round #296 (Div. 2) A. Playing with Paper

    A. Playing with Paper One day Vasya was sitting on a not so interesting Maths lesson and making an o ...

  2. 水题 Codeforces Round #296 (Div. 2) A. Playing with Paper

    题目传送门 /* 水题 a或b成倍的减 */ #include <cstdio> #include <iostream> #include <algorithm> ...

  3. CF527A:Playing with Paper——题解

    https://vjudge.net/problem/CodeForces-527A http://codeforces.com/problemset/problem/527/A 题目大意:一个纸长a ...

  4. [codeforces] 527A Playing with Paper

    原题 简单的gcd #include<cstdio> #include<algorithm> typedef long long ll; using namespace std ...

  5. A. Playing with Paper

    这是Codeforces Round #296 (Div. 2)的A题,题意就是: 小明有一张长为a,宽为b的纸,每当要折纸鹤时,就从纸上剪下一个正方形,然后,剩下的纸还可以剪出正方形,要是剩下的纸刚 ...

  6. 【codeforces 527A】Playing with Paper

    [题目链接]:http://codeforces.com/contest/527/problem/A [题意] 让你每次从一个长方形里面截出一个边长为长方形的较短边的正方形; 然后留下的部分重复上述步 ...

  7. CF 327D - Block Tower 数学题 DFS 初看很难,想通了就感觉很简单

    D. Block Tower time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...

  8. 【奶昔队ROUND#1】

    奶昔队Round #1 热身 (奶昔队不是真正的队,是群) CodeForces 435C Cardiogram 模拟,不过我做的时候不是模拟,是计算...(写了好久,还wa了几次),现在看了别人的代 ...

  9. CodeForces Round #296 Div.2

    A. Playing with Paper 如果a是b的整数倍,那么将得到a/b个正方形,否则的话还会另外得到一个(b, a%b)的长方形. 时间复杂度和欧几里得算法一样. #include < ...

随机推荐

  1. 第二百六十七天 how can I 坚持

    晚上有点小郁闷,小纠结,感觉不应该买房,不知道什么吸引着我一定要买呢,曾经坚持不买房的我,为什么成了这个样子. 搞不懂啊. 元旦就要就看房了, 如果真的要买了,明年的压力就会很大了. 经济到底会成为啥 ...

  2. Can jxta be used to develop online card game (p2p style)?

    Can jxta be used to develop online card game (p2p style)? https://www.java.net//node/677134 I am new ...

  3. vector 的resize与reserve

    最近遇到一个坑,简单说来是resize与reserve的功能混淆了. 如下: 如果调用resize的化,编译会出错,如果给Text提供默认构造函数,则可以编译通过,最终输出的结果为10. 如果调用re ...

  4. codeforces 630C Lucky Numbers

    C. Lucky Numbers time limit per test 0.5 seconds memory limit per test 64 megabytes input standard i ...

  5. TQJson序列和还原clientdataset.data

    TQJson是QDAC开源项目的JSON对象,其特点是跨平台,功能强大. 序列 procedure TForm2.Button2Click(Sender: TObject);var AJson: TQ ...

  6. Educational Codeforces Round 1(D. Igor In the Museum) (BFS+离线访问)

    题目链接:http://codeforces.com/problemset/problem/598/D 题意是 给你一张行为n宽为m的图 k个询问点 ,求每个寻问点所在的封闭的一个上下左右连接的块所能 ...

  7. ssi整合报错org.apache.struts2.convention.ConventionsServiceImpl.determineResultPath(ConventionsServiceImpl.java:100)

    java.lang.RuntimeException: Invalid action class configuration that references an unknown class name ...

  8. Android系统中Parcelable和Serializable的区别

    转载:https://greenrobot.me/devpost/android-parcelable-serializable/ 进行Android开发的时候,我们都知道不能将对象的引用传给Acti ...

  9. SQL Server中如何获取当前年,月,日,时,分,秒

    分类: SQL Server  select GETDATE() as '当前日期',DateName(year,GetDate()) as '年',DateName(month,GetDate()) ...

  10. Activator.CreateInstance 方法 (Type) 的用法

    转自:http://www.cnblogs.com/lmfeng/archive/2012/01/30/2331666.html Activator.CreateInstance 方法 (Type) ...