当前位置:网站首页>Codeforces round 296 (Div. 2) A. playing with paper[easy to understand]
Codeforces round 296 (Div. 2) A. playing with paper[easy to understand]
2022-07-07 20:45:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm the king of the whole stack .
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.
The question : Give one a * b Board of , Ask how many squares can be cut according to the method given in the question .
analysis : Direct recursive solution .
AC Code :
#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; // I began to forget to consider division .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;
}
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/116387.html Link to the original text :https://javaforall.cn
边栏推荐
- 字符串中数据排序
- OneSpin 360 DV新版发布,刷新FPGA形式化验证功能体验
- Numerical method for solving optimal control problem (0) -- Definition
- 让这个CRMEB单商户微信商城系统火起来,太好用了!
- 寫一下跳錶
- CodeSonar网络研讨会
- The latest version of codesonar has improved functional security and supports Misra, c++ parsing and visualization
- Mongodb learn from simple to deep
- 华泰证券可以做到万一佣金吗,万一开户安全嘛
- 机械臂速成小指南(十二):逆运动学分析
猜你喜欢
恶魔奶爸 B3 少量泛读,完成两万词汇量+
Nebula importer data import practice
C语言多角度帮助你深入理解指针(1. 字符指针2. 数组指针和 指针数组 、数组传参和指针传参3. 函数指针4. 函数指针数组5. 指向函数指针数组的指针6. 回调函数)
OneSpin | 解决IC设计中的硬件木马和安全信任问题
Codesonar enhances software reliability through innovative static analysis
万字总结数据存储,三大知识点
Intelligent software analysis platform embold
Is embedded system really safe? [how does onespin comprehensively solve the IC integrity problem for the development team]
How to meet the dual needs of security and confidentiality of medical devices?
Cantata9.0 | new features
随机推荐
Small guide for rapid formation of manipulator (11): standard nomenclature of coordinate system
华泰证券可以做到万一佣金吗,万一开户安全嘛
目前股票开户安全吗?可以直接网上开户吗。
AADL inspector fault tree safety analysis module
实战:sqlserver 2008 扩展事件-XML转换为标准的table格式[通俗易懂]
Write a jump table
使用高斯Redis实现二级索引
How to choose fund products? What fund is suitable to buy in July 2022?
JNI 初级接触
Klocwork code static analysis tool
数值法求解最优控制问题(〇)——定义
I Basic concepts
AADL Inspector 故障树安全分析模块
智能交通焕发勃勃生机,未来会呈现哪些巨变?[通俗易懂]
FTP steps for downloading files from Huawei CE switches
Tensorflow2. How to run under x 1 Code of X
Data sorting in string
让这个CRMEB单商户微信商城系统火起来,太好用了!
Jetty:配置连接器[通俗易懂]
部署、收回和删除解决方式—-STSADM和PowerShell「建议收藏」