Codeforces Round #296 (Div. 2) A. Playing with Paper[通俗易懂]

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

大家好,又见面了,我是全栈君。

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.


Codeforces Round #296 (Div. 2) A. Playing with Paper[通俗易懂]

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.


Codeforces Round #296 (Div. 2) A. Playing with Paper[通俗易懂]

题意:给一a * b的板,问依照题中所给方法可以裁成多少正方形。

解析:直接递归即解。

AC代码:

#include <cstdio>
#include <cstring>
#define LL long long

LL solve(LL a, LL b){
	if(b == 1) return a;
	if(a % b == 0) return a / b;              //開始忘了考虑整除。RE on test #7
	return solve(b, a % b) + (a / b);
}

int main(){
//	freopen("in.txt", "r", stdin);
	LL a, b;
	while(scanf("%lld%lld", &a, &b)==2){
		printf("%lld\n", solve(a, b));
	}
	return 0;
}

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/116387.html原文链接:https://javaforall.cn

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)
blank

相关推荐

  • python实现 最短路径算法

    python实现 最短路径算法一、Floyd-Warshall算法1.算法简介Floyd-Warshall算法是解决任意两点间的最短路径的一种算法。通常可以在任何图中使用,包括有向图、带负权边的图。存储方式采用邻接矩阵2.示例0 1 2 6 3 1 0 3 5 2 2 3 0 8 5 6 5 8 0 …

  • Hadoop入门——初识Hadoop

    Hadoop入门——初识Hadoop推荐一个微信商城,扫码即可购买,性价比超高,程序员必备店主就是博主,有任何问题可随时通过商城内的微信与博主取得联系一.hadoop是什么Hadoop被公认是一套行业大数据标准开源软件,在分布式环境下提供了海量数据的处理能力。几乎所有主流厂商都围绕Hadoop开发工具、开源软件、商业化工具和技术服务。今年大型IT公司,如EMC、Microsoft、Intel、Teradata、…

  • 细谈微商分销系统开发对企业的发展是好还是坏「建议收藏」

    细谈微商分销系统开发对企业的发展是好还是坏「建议收藏」  微商分销系统开发,,微商二级分销系统,微商系统开发,微商软件。微商APP开发,微商分销模式,微商全返系统,微商返利系统,微商管理系统。  从各个层面和角度,全方位解决微商品牌企业,在渠道中的一切微商管理问题,让微商品牌和团队轻松应对市场。  一、微商分销系统的特点  1.当你成为产品的代理商之后,你可以选择多种发货模式,平台或推广者可以选择发货模式。  …

  • java怎么写工业上位机软件_上位机软件类编写心得

    java怎么写工业上位机软件_上位机软件类编写心得usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;usingSystem.IO.Ports;usingSystem.IO;usingSystem.Xml;namespacelesson{publicpartialclassSComA…

  • 如何使用cmd进入MySQL

    如何使用cmd进入MySQL同时按下键盘上的win徽标+R,选择cmd,回车键打开cmd,在命令行中输入mysql-uroot-p切记只有这句话“mysql-uroot-p”,p后面没有分号“;”,否则就会报出以下错误,即提醒使用者不要在cmd命令行中输入密码,这种做法是不安全的。正确示例:C:\Users\hemiao>mysql-uroot-pEnterpassword:******WelcometotheMySQLmonitor.Commandsendwith;or

  • 值得收藏:一份非常完整的 MySQL 规范(一)[通俗易懂]

    值得收藏:一份非常完整的 MySQL 规范(一)

发表回复

您的电子邮箱地址不会被公开。

关注全栈程序员社区公众号