Codeforces Round #296 (Div. 2)--a long long--playing with Paper

Source: Internet
Author: User

One day Vasya is sitting on a not so interesting Maths lesson and making an origami from a rectangular a mm x B mm sheet of paper (a > b). Usually the first step in making an origami was making a square piece of paper from the rectangular sheet by folding the sh 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 x b mm strip of paper. He got the idea-to-use this strip of paper in the same-to-make an origami, and then use the remainder (if it exists) a nd so on. At the moment when he's left with a square piece of paper, he'll make the last ship from it and stop.

Can determine how many ships Vasya would make during the lesson?

Input

The first line of the input contains integers a, b (1≤ b < a ≤10)-the sizes of the original sheet of paper.

Output

Print a single integer-the number of ships that Vasya would 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.

Note: Notice long long to use LLD output, but CF can not use cout, with D results in the back has been 0-0-good supernatural

typedef long long ll; convenient

#include <cstdio>#include<algorithm>#include<iostream>using namespaceStd;typedefLong Longll;intMain () {ll A, B; LL Flag=0; CIN>> a >>b; if(A >b); Else{ll temp=A; A=b; b=temp; }     while(a%b) {Flag+ =/b; ll temp=b; b= A-(A/b) *b; A=temp; } Flag+ =/b; cout<<Flag;}
View Code

Codeforces Round #296 (Div. 2)--a long long--playing with Paper

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.