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


相关推荐

  • IIS真正能用的ISAPI-Rewrite防盗链规则写法

    IIS真正能用的ISAPI-Rewrite防盗链规则写法本规则支持白名单排除式防盗链,搜索引擎友好不屏蔽,被盗链后的错误提示转向,支持各种文件类型,经作者亲验真的能用,第一时间在原创发表,请继续往下阅读。近来小站遇到了盗链问题,至使网站的流量枉费流失,于是被迫准备为服务器安装防盗链机制以挽救本就不宽裕的带宽。通过G.CN和B.CN搜索后得出了几种不同的方案,例如网站程序的URL伪装法、服务器端的收费插件法和ISAPI-R…

    2022年7月23日
    9
  • pycharm django环境搭建_宝塔Linux怎么搭建asp程序

    pycharm django环境搭建_宝塔Linux怎么搭建asp程序今天来简单总结一下使用Pycharm和Django来搭建一个最简单的PythonWeb应用(就是我们所说的‘HelloWorld’)。在这里,我们首先假设已经安装好了Python(2.x和3.x版本均可)。安装Django  无论是Python2.x还是Python3.x版本,都可以使用pip来安装Django。在控制台使用如下命令:pipinstalldjango安装成功后,在i

    2022年8月28日
    3
  • Mac下查看Tomcat版本「建议收藏」

    终端进入Tomcat目录找到bin下shcatalina.shversion转载于:https://my.oschina.net/u/4013710/blog/30486…

    2022年4月13日
    41
  • Python for循环的使用

    Python for循环的使用Pythonfor循环的使用(一)for循环的使用场景1.如果我们想要某件事情重复执行具体次数的时候可以使用for循环。2.for循环主要用来遍历、循环、序列、集合、字典,文件、甚至是自定义类或函数。(二)for循环操作列表实例演示使用for循环对列表进行遍历元素、修改元素、删除元素、统计列表中元素的个数。1.for循环用来遍历整个列表#for循环主

    2022年8月12日
    8
  • vue可以和jquery一起用吗_项目中vue和jquery一起如何使用

    vue可以和jquery一起用吗_项目中vue和jquery一起如何使用拿起html的时候,在数据处理上,疯狂怀念数据双向绑定,vue又成了我的必选项,但是有些业务场景其实并不适用vue,所以最终技术选型为vue+jquery混合使用,结合两边的优点,大大提高开发效率。vue和jquery同时引入的时候,jquery操作一定要放在vue后面,要等DOM渲染完成,jquery才能进行DOM事件操作。那么vue+jquery应该如何使用呢?一、首先引入vue文件(cdn或者下载到本地都行),参考vue官方连接https://cn.vuejs.org/v2/guide/ins

    2022年10月15日
    2
  • spring事务管理全解析

    spring事务管理全解析

    2021年5月9日
    96

发表回复

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

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