当前位置:网站首页>Codeforces Round #296 (Div. 2) A. Playing with Paper[通俗易懂]
Codeforces Round #296 (Div. 2) A. Playing with Paper[通俗易懂]
2022-07-07 20:03:00 【全栈程序员站长】
大家好,又见面了,我是全栈君。
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.
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.
题意:给一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.cn/116387.html原文链接:https://javaforall.cn
边栏推荐
- 使用高斯Redis实现二级索引
- When easygbs cascades, how to solve the streaming failure and screen jam caused by the restart of the superior platform?
- 嵌入式系统真正安全了吗?[ OneSpin如何为开发团队全面解决IC完整性问题 ]
- 反诈困境,国有大行如何破局?
- Helix QAC 2020.2 new static test tool maximizes the coverage of standard compliance
- Tensorflow2. How to run under x 1 Code of X
- 复杂因子计算优化案例:深度不平衡、买卖压力指标、波动率计算
- 恢复持久卷上的备份数据
- Phoenix JDBC
- 数值法求解最优控制问题(〇)——定义
猜你喜欢
上海交大最新《标签高效深度分割》研究进展综述,全面阐述无监督、粗监督、不完全监督和噪声监督的深度分割方法
Intelligent software analysis platform embold
Network principle (1) - overview of basic principles
Static analysis of software defects codesonar 5.2 release
Klocwork 代码静态分析工具
How does codesonar help UAVs find software defects?
CodeSonar如何帮助无人机查找软件缺陷?
Onespin | solve the problems of hardware Trojan horse and security trust in IC Design
Apifox 接口一体化管理新神器
ERROR: 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your
随机推荐
凌云出海记 | 易点天下&华为云:推动中国电商企业品牌全球化
[paper reading] maps: Multi-Agent Reinforcement Learning Based Portfolio Management System
Klocwork code static analysis tool
Codesonar Webinar
Static analysis of software defects codesonar 5.2 release
恶魔奶爸 A3阶段 近常速语流初接触
Dachang classic pointer written test questions
You want to kill a port process, but you can't find it in the service list. You can find this process and kill it through the command line to reduce restarting the computer and find the root cause of
Deep learning model compression and acceleration technology (VII): mixed mode
Referrer和Referrer-Policy简介
华为CE交换机下载文件FTP步骤
Ubuntu安装mysql8遇到的问题以及详细安装过程
C语言多角度帮助你深入理解指针(1. 字符指针2. 数组指针和 指针数组 、数组传参和指针传参3. 函数指针4. 函数指针数组5. 指向函数指针数组的指针6. 回调函数)
微服务远程Debug,Nocalhost + Rainbond微服务开发第二弹
Mongodb learn from simple to deep
想杀死某个端口进程,但在服务列表中却找不到,可以之间通过命令行找到这个进程并杀死该进程,减少重启电脑和找到问题根源。
ERROR: 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your
FTP steps for downloading files from Huawei CE switches
AADL inspector fault tree safety analysis module
【函数递归】简单递归的5个经典例子,你都会吗?