当前位置:网站首页>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
边栏推荐
- Cantata9.0 | 全 新 功 能
- Prometheus remote_write InfluxDB,unable to parse authentication credentials,authorization failed
- 图扑数字孪生煤矿开采系统,打造采煤“硬实力”
- Micro service remote debug, nocalhost + rainbow micro service development second bullet
- Alibaba cloud award winning experience: how to mount NAS file system through ECS
- Deep learning model compression and acceleration technology (VII): mixed mode
- Codesonar enhances software reliability through innovative static analysis
- 使用 BR 备份 TiDB 集群数据到 Azure Blob Storage
- 如何满足医疗设备对安全性和保密性的双重需求?
- [function recursion] do you know all five classic examples of simple recursion?
猜你喜欢
OneSpin | 解决IC设计中的硬件木马和安全信任问题
Static analysis of software defects codesonar 5.2 release
Helix QAC 2020.2 new static test tool maximizes the coverage of standard compliance
使用高斯Redis实现二级索引
【论文阅读】MAPS: Multi-agent Reinforcement Learning-based Portfolio Management System
Ubuntu安装mysql8遇到的问题以及详细安装过程
Mongodb learn from simple to deep
MySQL约束之默认约束default与零填充约束zerofill
95年专注安全这一件事 沃尔沃未来聚焦智能驾驶与电气化领域安全
上海交大最新《标签高效深度分割》研究进展综述,全面阐述无监督、粗监督、不完全监督和噪声监督的深度分割方法
随机推荐
MySQL约束之默认约束default与零填充约束zerofill
使用 BR 恢复 Azure Blob Storage 上的备份数据
Static analysis of software defects codesonar 5.2 release
九度 1201 -二叉排序数遍历- 二叉排序树「建议收藏」
Write a jump table
Micro service remote debug, nocalhost + rainbow micro service development second bullet
上海交大最新《标签高效深度分割》研究进展综述,全面阐述无监督、粗监督、不完全监督和噪声监督的深度分割方法
神兵利器——敏感文件发现工具
Data sorting in string
恶魔奶爸 B3 少量泛读,完成两万词汇量+
Flask1.1.4 Werkzeug1.0.1 源码分析:路由
OneSpin | 解决IC设计中的硬件木马和安全信任问题
使用camunda做工作流设计,驳回操作
Make this crmeb single merchant wechat mall system popular, so easy to use!
When easygbs cascades, how to solve the streaming failure and screen jam caused by the restart of the superior platform?
Ubuntu安装mysql8遇到的问题以及详细安装过程
Is it safe to open a stock account at present? Can I open an account online directly.
论文解读(ValidUtil)《Rethinking the Setting of Semi-supervised Learning on Graphs》
Nebula importer data import practice
Postgresql数据库character varying和character的区别说明