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


相关推荐

  • c++打印倒直角三角形(平行四边形等边三角形)

    标题与思路:①正三角//正三角voidregularTriangle(inta){ cout<<“※正三角\n”; for(inti=0;i<a;i++) { for(intj=a;j>i+1;j–) cout<<“”; for(intj=0;j<i+1;j++) cout<<“*”; cout<<“\n”; }}②倒三

    2022年4月10日
    168
  • mybatis拦截器不能拦截哪个类_信号发生器的使用方法总结

    mybatis拦截器不能拦截哪个类_信号发生器的使用方法总结文章目录1.基础介绍1.1.核心对象1.2.执行过程2.实现步骤2.1.添加注解2.1.1.type2.1.2.method2.1.3.args2.2.方法实现2.2.1.intercept2.2.2.plugin2.2.3.setProperties3.代码示例MyBatis拦截器可以做的工作:SQL修改,分页操作,数据过滤,SQL执行时间性能监控等。1.基础介绍1.1.核心对象从MyBatis代码实现的角度来看,MyBatis的主要的核心部件有以下几个:Con

    2025年10月15日
    3
  • 魔兽争霸微操教学(精华篇)「建议收藏」

    魔兽争霸微操教学(精华篇)「建议收藏」基础操作:用键盘制造单位,释放魔法,使用物品。魔兽中的一切东西都可以用快捷键来完成,而鼠标只是起到一个定位的作用。比如,暗夜做小精灵,你可以用鼠标点击基地里精灵的头像,也可以直接按w;或者暗夜做月亮

    2022年7月1日
    32
  • 深度学习100例-循环神经网络(LSTM)实现股票预测 | 第10天

    深度学习100例-循环神经网络(LSTM)实现股票预测 | 第10天文章目录一、前言二、LSTM的是什么三、准备工作1.设置GPU2.设置相关参数3.加载数据四、数据预处理1.归一化2.时间戳函数五、构建模型六、激活模型七、训练模型八、结果可视化1.绘制loss图2.预测3.评估一、前言今天是第10天,我们将使用LSTM完成股票开盘价格的预测,最后的R2可达到0.74,相对传统的RNN的0.72提高了两个百分点。我的环境:语言环境:Python3.6.5编译器:jupyternotebook深度学习环境:TensorFlow2.4.1来自专栏:【深度学习

    2022年6月16日
    30
  • 理解通配符掩码

    理解通配符掩码一、什么是通配符掩码通配符掩码是一个32位比特数,以点分十进制表示,告诉路由器数据包IP地址的哪些比特需要和access-list命令中给定的IP地址相匹配。二、通配符掩码的作用一条典型的ACL仅能指定一个要允许或拒绝IP的规则,如果要阻止多个地址或一段范围的地址,那么如使用典型的ACL规则,则需要添加多条才能满足。这样导致工作量增多,易出错且ACL执行效率…

    2022年7月24日
    17
  • 邀您免费加入到程序猿小密圈

    邀您免费加入到程序猿小密圈

    2022年3月13日
    47

发表回复

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

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