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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 如何使用等价类划分法编写测试用例的结果_划分等价类设计测试用例

    如何使用等价类划分法编写测试用例的结果_划分等价类设计测试用例案例:如下图所示的一个两位整数加法器,需求分析中要求:①第一个数和第二个数都是只能输入-99到99之间的整数②对于输入的小于-99的数据或者大于99的数据,程序应给出明确提示③对于输入的小数、字符等非法数据,程序应给出明确提示基于上述需求,使用等价类划分法编写测试用例的步骤如下:1.根据需求分析,建立等价类表(1)有效等价类表编号数据要求1-99——0之间的整…

    2022年10月17日
    2
  • Laravel [1045] 解决方法 Access denied for user ‘homestead’@’localhost’

    Laravel [1045] 解决方法 Access denied for user ‘homestead’@’localhost’

    2021年10月27日
    65
  • jsonobject是什么类型_json和jsonobject区别

    jsonobject是什么类型_json和jsonobject区别JSONObject是一种数据结构,可以理解为JSON格式的数据结构(key-value结构),可以使用put方法给json对象添加元素。JSONObject可以很方便的转换成字符串,也可以很方便的把其他对象转换成JSONObject对象。一、构建json1、实例化一个JSONObject对象,用put()方法将数据写入。JSONObjectobj=newJSONObject(…

    2022年9月2日
    5
  • 家庭服务器配置(云服务器解决方案)

    家庭服务器解决方案——硬件篇2021-07-1622:41:5829点赞193收藏36评论关于服务器我一直有个设想:未来每个人都有一个专属服务器。这个服务器是每个人在互联网的数据中枢。这个服务器:安全,只有所有者拥有管理权限;强大,可以存储数据并保护隐私。当人离开世界时,可以选择把一些数据留给家人,也可以选择把自己在互联网的记忆全部抹去……当然现在并没有我设想的那种服务器,所以不如聊聊更实际的家…

    2022年4月10日
    232
  • 中图法中的分类号通常由哪两部分组成_北京航空航天大学排名

    中图法中的分类号通常由哪两部分组成_北京航空航天大学排名 V航空、航天   V1航空、航天技术的研究与探索     V11航空、航天的发展与空间探索     V19航空、航天的应用   V2航空     [V2-9]航空运输经济     V21基础理论及试验       V211空气动力学         V211.1理论空气动力学           V21

    2022年10月2日
    4
  • intellijidea激活码2021【2021最新】

    (intellijidea激活码2021)JetBrains旗下有多款编译器工具(如:IntelliJ、WebStorm、PyCharm等)在各编程领域几乎都占据了垄断地位。建立在开源IntelliJ平台之上,过去15年以来,JetBrains一直在不断发展和完善这个平台。这个平台可以针对您的开发工作流进行微调并且能够提供…

    2022年3月21日
    66

发表回复

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

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