XiaoPANGXia的专栏

One day Vasya was sitting on a not so interesting Maths lesson and making an origami from a rectangulara 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

Note

Pictures to the first and second sample test.

意思就是给一张矩形的纸,,不断地以其短边去折正方形,裁掉折出来的正方形,接着对剩下的部分重复操作,知道最后裁去的和剩下的都是正方形为止,给你最初矩形的长宽,问最终会裁出多少个矩形。

这个题做法就和14年西安的k题做法一样,不过这题不叫明显,西安那个还不容易想到。就是模仿gcd的做法取模、取商、参数换位、递归,把每次的商加起来就是了。

代码:

<span style="font-size:12px;color:#000000;">#include <iostream>#include<stdio.h>using namespace std;long long int a,b,res;long long int work(long long int a,long long int b){if(b==0)return 0;else{return a/b+work(b,a%b);}}int main(){scanf("%I64d%I64d",&a,&b);res=work(a,b);printf("%I64d\n",res);return 0;}</span>

在旅途中,我遇见了你,你我相识是缘分!

XiaoPANGXia的专栏

相关文章:

你感兴趣的文章:

标签云: