P7036 [NWRRC2016] Folding
题目简述
有两个矩形,大小分别是 \(W \times Y\) 和 $ w \times y$。现在我们要通过折叠将两个矩阵变成一样。
思路
part1
已知一条边折叠一次会变成 \(\frac{x}{2}\) 到 \(x\) 之间的一个数,所以我们把大矩形折叠到两条边都小于小矩形的两边,然后每次折叠记录一个 \(ans\) 最后输出就行了。(用这种方式需要用 \(float\))
part2
或者我们反着来,每次把小矩形的边乘二,直到都大于大矩形的两条边。
and
这道题没有保证 \(W\) 和 \(H\) 一定大于 \(w\) 和 \(h\),所以我们还需要加一个特判。
code
#include <bits/stdc++.h>
#define int long long
using namespace std;
int n,m,n1,m1;
float x,y,xx,yy;
int ans=0;
signed main(){
cin>>n>>m>>n1>>m1;
x=min(n,m),y=max(n,m);
xx=min(n1,m1),yy=max(n1,m1);
if(x<xx||y<yy){cout<<-1<<endl;return 0;}
while(xx<x||yy<y){
if(y>yy) y/=2;
else x/=2;
if(x>y)swap(x,y);
ans++;
}
cout<<ans<<endl;
return 0;
}
#include <bits/stdc++.h>
#define int long long
using namespace std;
int n,m,n1,m1;
int x,y,xx,yy;
int ans=0;
signed main(){
cin>>n>>m>>n1>>m1;
x=max(n,m),y=min(n,m);
xx=max(n1,m1),yy=min(n1,m1);
if(x<xx||y<yy){cout<<-1<<endl;return 0;}
while(xx<x||yy<y){
if(yy<y) yy*=2;
else xx*=2;
if(xx<yy) swap(xx,yy);
ans++;
}
cout<<ans<<endl;
return 0;
}
P7036 [NWRRC2016] Folding的更多相关文章
- Codeforces Gym 100002 Problem F "Folding" 区间DP
Problem F "Folding" Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/ ...
- eclipse 插件之Code Folding
功能: eclipse自带折叠包括方法, import, 注释等得折叠功能, code folding 插件对其增强. 1. 下载插件:( 也可以用link方式, 我的是link安装, jar包网上很 ...
- Android Folding View(折叠视图、控件)
版本号:1.0 日期:2014.4.21 版权:© 2014 kince 转载注明出处 非常早之前看过有人求助以下这个效果是怎样实现的, 也就是側滑菜单的一个折叠效果,事实上关于这个效果的实现,谷 ...
- Chrome Dev Tools: Code Folding in CSS and Javascript for improved code readiability
Note : Apply for google chrome canary. You can fold code blocks in CSS (and Sass) and javascript fil ...
- Codeforces Round #397 by Kaspersky Lab and Barcelona Bootcamp (Div. 1 + Div. 2 combined) E. Tree Folding 拓扑排序
E. Tree Folding 题目连接: http://codeforces.com/contest/765/problem/E Description Vanya wants to minimiz ...
- Eclipse折叠代码 coffee bytes code folding
提供一个插件下载地址,博客园的: http://files.cnblogs.com/wucg/com.cb.eclipse.folding_1.0.6.jar.zip 将下载的zip文件解压出来的j ...
- poj2176 Folding【区间DP】
Folding Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 1841 Accepted: 642 Special ...
- Codeforces Round #397 by Kaspersky Lab and Barcelona Bootcamp (Div. 1 + Div. 2 combined) E. Tree Folding
地址:http://codeforces.com/contest/765/problem/E 题目: E. Tree Folding time limit per test 2 seconds mem ...
- UVA1630 Folding 区间DP
Folding Description Bill is trying to compactly represent sequences of capital alphabetic characte ...
- Ural 1238 Folding 题解
目录 Ural 1238 Folding 题解 题意 题解 程序 Ural 1238 Folding 题解 题意 定义折叠.展开为: 单个大写英文字母是一个折叠的串,把它展开后是它本身. 如果\(S\ ...
随机推荐
- 听说火山引擎推出的 DataLeap,已经可以支持万级表的数据血缘图谱了!
更多技术交流.求职机会,欢迎关注字节跳动数据平台微信公众号,回复[1]进入官方交流群 数据来源广.量级大.场景多,导致数据之间关系变得异常复杂. 经过读取.清洗.存储.计算等一系列流程之后,数据最终汇 ...
- HF Hub 现已加入存储区域功能
我们在 企业版 Hub 服务 方案中推出了 存储区域(Storage Regions) 功能. 通过此功能,用户能够自主决定其组织的模型和数据集的存储地点,这带来两大显著优势,接下来的内容会进行简要介 ...
- 【Vue】大总结
目录 vue大回顾 模板语法处理xss攻击 Vue单页面组件 ts泛型 sass\less\css的区别 ...toRef() defineEmits 练习 根据分数显示颜色 vue大回顾 1 前端发 ...
- anaconda学习(未完成)
1.Anaconda安装教程(以32.7.4为例)官网地址:https://www.anaconda.com/download(如无法下载可跳转清华源下载)下载完成后点击打开即可安装点击Next选择I ...
- SpringBoot 项目实战 | 瑞吉外卖 Day05
该系列将记录一份完整的实战项目的完成过程,该篇属于第五天 案例来自B站黑马程序员Java项目实战<瑞吉外卖>,请结合课程资料阅读以下内容 该篇我们将完成以下内容: 新增套餐 套餐信息分页查 ...
- 【每日一题】39. Contest(树状数组 / 容斥分治)
补题链接:Here 算法涉及:树状数组.CDQ分治 n支队伍一共参加了三场比赛. 一支队伍x认为自己比另一支队伍y强当且仅当x在至少一场比赛中比y的排名高. 求有多少组(x,y),使得x自己觉得比y强 ...
- Codeforces Round #667 (Div. 3) A - D题题解
Codeforces Round #667 (Div. 3) A - D Problem A - Yet Another Two Integers Problem https://codeforces ...
- Codeforces Round #674 (Div. 3) (A - F题题解)
A. Floor Number https://codeforces.com/contest/1426/problem/A 题意: 一个楼房房间号由 \(1\) 递增,一楼仅2个房间.给定一位用户的房 ...
- C++ bitset的简单使用
bitset 一般代替 bool 数组使用,常用于优化空间,因为 bitset 中一个元素只占 1 bit. bitset 的大小在定义使就需要确定.如果想要不定长的 bitset,就需要使用 vec ...
- 基于函数计算自定义运行时快速部署一个 springboot 项目 什么是函数计算?
什么是函数计算? 函数计算是事件驱动的全托管计算服务.使用函数计算,您无需采购与管理服务器等基础设施,只需编写并上传代码.函数计算为您准备好计算资源,弹性地可靠地运行任务,并提供日志查询.性能监控和报 ...