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\ ...
随机推荐
- 火山引擎 DataTester 上线“流程画布”功能,支持组合型 A/B 实验分析
更多技术交流.求职机会,欢迎关注字节跳动数据平台微信公众号,回复[1]进入官方交流群 在精细化运营的时代,运营活动同样需要有精细化的策略,例如在年末大促活动中,设计 APP 弹窗提醒.满减.会员领券时 ...
- PPT 笔刷:让你的PPT充满视觉冲击
其实就是下载的AI效果 辅助文字展示 辅助图片展示 创意展示图片,增强视觉冲击力 使用 删除外面的边框 https://www.bilibili.com/video/BV1ha411g7f5?p=16
- MAC 转 Byte[] 数组
MAC 转 Byte[] 数组 /** * MAC 地址转 byte[] * 默认以小端序转换 * * @param macAddr "E4:54:E8:81:FC:FD" * @ ...
- Docker--镜像&&容器基本操作
1 基础镜像 BusyBox 一个极简版的Linux系统 集成了100多种常用Linux命令 大小不到2MB 适用于简单测试场景 Alpine 一个面向安全的轻型Linux发行版系统 比BusyBox ...
- 【HZERO】feign调用
feign调用 https://open.hand-china.com/community/detail/603204901962649600 # Hiam获取用户信息示例
- 【HZERO】数据导入
#数据导入 ##文档整理 通用导入客户端 https://open.hand-china.com/hzero-docs/v1.3/zh/docs/service/import/import/ 开放平台 ...
- C 与 C++ 区别
C 与 C++ 区别 本文介绍 C 与 C++ 之间重要的或者容易忽略的区别.尽管 C++ 几乎是 C 的超集,C/C++ 代码混用一般也没什么问题,但是了解 C/C++ 间比较重要区别可以避免碰到一 ...
- vivo 悟空活动中台 - H5 活动加载优化
本文首发于 vivo互联网技术 微信公众号 链接: https://mp.weixin.qq.com/s/6gtVR0nVNcZvREjwftZgzA作者:悟空中台研发团队 [悟空活动中台]系列往期精 ...
- jdk1.8: Consumer函数
场景: 当我们在a方法中,需要把某些参数赋值给一个Integer类型的对象,而该对象只有在b方法才能赋值,那么我们可以在a方法中使用consumer记录我们要执行的操作,再把consumer作为参数传 ...
- distributor和gateway联合实现出中继的负载均衡+故障转移
概述 freeswitch是一款简单好用的VOIP开源软交换平台. 在之前的文章,我们介绍过distributor模块实现多线路分发的配置方法,但是当线路发生故障时,distributor并不会自动跳 ...