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


相关推荐

  • XRDP与VNC的关系

    XRDP与VNC的关系

    2022年2月3日
  • c语言中图书管理系统_c语言图书管理系统排序

    c语言中图书管理系统_c语言图书管理系统排序课件C语言图书管理系统代码#include#include#includestructbook{intnum;charbname[50];charwname[20];charpress[50];charsort[50];inttime;floatprice;structbook*next;};structbook*creatbook();…

    2022年8月31日
  • 单片机应用基础知识_51单片机基础知识总结

    单片机应用基础知识_51单片机基础知识总结单片机——硬件基础知识宗旨:技术的学习是有限的,分享的精神是无限的。1、单片机内部资源STC89C52:8KFLASH、512字节RAM、32个IO口、3个定时器、1个UART、8个中断源(1)Flash(硬盘)——程序存储空间——擦写10万次,断电数据不丢失,读写速度慢(2)RAM(内存)——数据存储空间——断电数据丢失

    2022年9月7日
  • TiKV 性能参数调优[通俗易懂]

    TiKV 性能参数调优[通俗易懂]2019独角兽企业重金招聘Python工程师标准>>>…

    2022年9月23日
  • 如何利用净推荐值(NPS)测量用户忠诚度?

    如何利用净推荐值(NPS)测量用户忠诚度?用户满意度是每个企业都非常关心的问题,满意度水平高的企业往往也有着良好的营收效益。相反,用户满意度较差的企业,也可以通过用户满意度的相关调研,深入了解自己的不足之处,哪些方面有待改进。如何通过简单的数据指标,科学有效地测量出用户满意度呢?今天我们将为大家介绍一种调研用户满意度的常用方法——净推荐值(NPS)NPS是什么NPS即净推荐值(NetPromoterScore),是一种计量客户将会向其他人推荐企业或服务可能性的指数。是目前最流行的顾客忠诚度分析指标。NPS净推荐值的数据收集方

    2022年4月29日
  • 关于爱在线观看无删减版_unique individual

    关于爱在线观看无删减版_unique individual  如声明了一个变量为uniqueidentifier,  可以用NewID()方法来生成一个唯一的uniqueidentifier变量DECLARE@FUUIDuniqueidentifierSET@FUUID=NEWID()INSERTINTOOPENDATASOURCE(‘SQLOLEDB’…

    2022年9月7日

发表回复

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

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