Codeforces Gym 101142 F. Folding
来源:互联网 发布:淘宝致一科技 编辑:程序博客网 时间:2024/05/22 11:48
题意
对于原
解题思路
反向模拟,
需要注意的是纸张可以展开,故长宽可对调。
代码
#include<bits/stdc++.h>using namespace std;const int INF = 1e9 + 7;long long W, H;int solve(long long w, long long h){ if(w > W || h > H) return INF; int cnt = 0; while(w < W) { w *= 2; cnt++; } while(h < H) { h *= 2; cnt++; } return cnt;}int main(){ freopen("folding.in", "r", stdin); freopen("folding.out", "w", stdout); long long w, h; scanf("%I64d %I64d %I64d %I64d", &W, &H, &w, &h); int ans = solve(w, h); ans = min(ans, solve(h, w)); printf("%d\n", ans == INF ? -1 : ans);}
阅读全文
0 0
- Codeforces Gym 101142 F. Folding
- Gym 101142F Folding
- Gym - 101142F Folding(折半)
- codeforces gym 101142 F(思维)
- codeforces Gym 101102F
- Codeforces-GYM-100726F
- Codeforces GYM 100803F
- Folding Gym
- 【Codeforces Gym 100187F 】+ 贪心
- codeforces-gym-100187-F【贪心】
- Codeforces gym 101350F 想法
- Codeforces Gym 101164 F. Letter
- Codeforces Gym 101473D Folding Machine DFS/XJBS
- codeforces gym 100342F Move to Front
- Codeforces Gym 100642 C D F
- Codeforces Gym-101116-F (Flight Plan)
- Codeforces Gym 100623F Problem F. Fenwick Tree
- Codeforces Gym 100342F Move to Front 平衡树
- 深入理解Spark 2.1 Core (九):迭代计算和Shuffle的原理与源码分析
- 第5章 数据类型和运算符
- 一种新的类型的密码管理软件Lesspass
- 新建线程的异常处理
- UNIX环境高级编程-读书笔记-网络编程(一)
- Codeforces Gym 101142 F. Folding
- Mapped Statements collection does not contain value for
- 阿里云centos7 部署java+tomcat+mysql运行环境
- 打印日志小结
- UNIX环境高级编程-读书笔记-网络编程(二)
- CButton重绘图片实现自由缩放和拖动
- 定制Eclipse右键new菜单
- kaldi下清华语音数据集的说话人测试脚本编写
- shell命令