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;
}

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

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

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 计算机组成原理 时钟周期_什么是指令周期机器周期和时钟周期

    计算机组成原理 时钟周期_什么是指令周期机器周期和时钟周期时钟周期:一个时钟脉冲所需要的时间。在计算机组成原理中又叫T周期或节拍脉冲。是CPU和其他单片机的基本时间单位。它可以表示为时钟晶振频率(1秒钟的时钟脉冲数)的倒数(也就是1s/时钟脉冲数,比如1/12MHz),对CPU来说,在一个时钟周期内,CPU仅完成一个最基本的动作。时钟脉冲是计算机的基本工作脉冲,控制着计算机的工作节奏。时钟频率越高,时钟周期就越短,工作速度也就越快。时钟周期在CPU的描述…

    2022年10月13日
    1
  • php 5 与7有什么区别

    php 5 与7有什么区别

    2021年11月10日
    41
  • java injector_java – Injector Hierarchy / Child Injector解释?「建议收藏」

    java injector_java – Injector Hierarchy / Child Injector解释?「建议收藏」Modules.override()在Stage.PRODUCTION中不起作用.您应该使用PrivateModule,其中绑定仅在私有模块内有效/可见,因此您可以将不同的实现类绑定到同一个接口.然后,您可以将Private模块安装到父模块,但是您必须显式公开()您希望其他模块可见的所有绑定.让我们说:DatabaseSearchModule.java(扩展PrivateModule)bind(P…

    2025年6月14日
    0
  • WebApp 开发框架推荐以及优缺点分析[通俗易懂]

    WebApp 开发框架推荐以及优缺点分析[通俗易懂]不用盲目的百度和问大神们WebApp开发使用哪个框架最好?等等问题。在此,小编尽量解答各位的WebApp 问题。根据国内js大神以及有过WebApp 开发经验的前辈们分析,小编推荐下面6款常用的WebApp 开发框架。第一款:Sencha TouchSenchaTouch是世界上第一个支持HTML5和CSS3标准的移动应用框架,你可以使用HTML5来编写音频和视频组件,还可以使用…

    2022年6月24日
    29
  • 彻底解决鼠标单击变双击问题的方法(图例)「建议收藏」

    彻底解决鼠标单击变双击问题的方法(图例)「建议收藏」两个月前,己“服役”了几年的鼠标出现了故障,单击经常变成双击,这样想用鼠标移动文件的时候就很麻烦,常常要移动几次才能成功。起初我怀疑是系统的问题,但鼠标在别的电脑上使用也出现同样的问题,因此确认鼠标本

    2022年8月1日
    14
  • IT行业分析(华为裁员)「建议收藏」

    IT行业分析(华为裁员)「建议收藏」近来忙于各种麻烦事务,知识图谱的多路归并一直未能跟进。但在写多路归并前,我想是时候先总结下我的这几年。总结的经验,不仅包括我个人这几年的见闻感悟与得失,也是80后这代的一个缩影,以及对社会的一些思考。首先直插正题,华为的裁员。华为我确实没呆过,不过这不妨碍我认定华为是一个人员流动性非常大的公司,和BAT、美团、京东、360、小米等等互联网公司一样大。谁更大我不知

    2022年7月18日
    35

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

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