博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
CF Playing with Paper
阅读量:6962 次
发布时间:2019-06-27

本文共 1921 字,大约阅读时间需要 6 分钟。

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
1 #include 
2 #include
3 using namespace std; 4 5 int main(void) 6 { 7 long long count; 8 long long a,b; 9 10 while(scanf("%lld%lld",&a,&b) != EOF)11 {12 count = 0;13 if(!(a % b))14 {15 cout << a / b << endl;16 continue;17 }18 19 int flag = 1;20 21 while((a % b))22 {23 count += a / b;24 a %= b;25 if(a < b)26 swap(a,b);27 if(a % b == 0)28 count += a / b;29 }30 cout << count << endl;31 }32 33 return 0;34 }

 

转载于:https://www.cnblogs.com/xz816111/p/4394650.html

你可能感兴趣的文章
以Drools5.5为例说明“规则引擎在业务系统中应用”---起始篇
查看>>
linux清理内存
查看>>
查看硬盘负载情况:iostat命令
查看>>
《人月神话》阅读笔记03
查看>>
Linux下防火墙开启相关端口及查看已开启端口
查看>>
php socket 编程(一)
查看>>
SDUT 简单枚举类型——植物与颜色
查看>>
Windows 下配置Git
查看>>
PD的CDM模型中的三种实体关系
查看>>
All you should know about NUMA in VMware!
查看>>
java 版本SQLHelper
查看>>
Hyper-V中的VM如何使用Pass-through Disk
查看>>
黑马程序员—Java动态代理详解
查看>>
PHP发送HEAD方法请求
查看>>
OracleHelper[.Net 连接Oracle数据库的封装类]
查看>>
.net微信公众号开发——消息与事件
查看>>
动态网站维护基本命令
查看>>
透视表提取不反复记录(2)-每一个物品的全部分类
查看>>
基于jQuery/CSS3实现拼图效果的相册插件
查看>>
【问题解决】小数点前面不显示0的问题
查看>>