题目简述

有两个矩形,大小分别是 \(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的更多相关文章

  1. Codeforces Gym 100002 Problem F "Folding" 区间DP

    Problem F "Folding" Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/ ...

  2. eclipse 插件之Code Folding

    功能: eclipse自带折叠包括方法, import, 注释等得折叠功能, code folding 插件对其增强. 1. 下载插件:( 也可以用link方式, 我的是link安装, jar包网上很 ...

  3. Android Folding View(折叠视图、控件)

    版本号:1.0 日期:2014.4.21 版权:© 2014 kince 转载注明出处 非常早之前看过有人求助以下这个效果是怎样实现的,   也就是側滑菜单的一个折叠效果,事实上关于这个效果的实现,谷 ...

  4. 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 ...

  5. 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 ...

  6. Eclipse折叠代码 coffee bytes code folding

    提供一个插件下载地址,博客园的: http://files.cnblogs.com/wucg/com.cb.eclipse.folding_1.0.6.jar.zip  将下载的zip文件解压出来的j ...

  7. poj2176 Folding【区间DP】

    Folding Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 1841   Accepted: 642   Special ...

  8. 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 ...

  9. UVA1630 Folding 区间DP

    Folding Description   Bill is trying to compactly represent sequences of capital alphabetic characte ...

  10. Ural 1238 Folding 题解

    目录 Ural 1238 Folding 题解 题意 题解 程序 Ural 1238 Folding 题解 题意 定义折叠.展开为: 单个大写英文字母是一个折叠的串,把它展开后是它本身. 如果\(S\ ...

随机推荐

  1. MySQL 创建存储过程注意项

    MySQL server version for the  right syntax to use near 'IF' MySQL server version for the right synta ...

  2. 动作捕捉系统验证OPT追踪井下无人机的性能

    井下无人机长时间在恶劣环境下执行勘测.救援任务,通讯系统可能会陷入两难的境地--传输高精度坐标伴随着大量耗能.为解决这项难题,中国矿业大学计算机科学和技术学院陈朋朋教授团队提出了一种基于超宽带(UWB ...

  3. TypeError: this.libOptions.parse is not a function

    安装完node.js运行项目后,报错: TypeError: this.libOptions.parse is not a function at ESLint8Plugin.<anonymou ...

  4. Deltix Round, Spring 2021 (open for everyone, rated, Div. 1 + Div. 2) (ABCE补题记录)

    补题链接:Here 1523A. Game of Life 生命游戏定义 本题中改编为一维坐标上的生命游戏 即使 \(m(m\in[1,1e9])\) 的范围很大,但每次进化不会超过 \(n\) 次, ...

  5. 悟空活动中台 - 基于 WebP 的图片高性能加载方案

    本文首发于 vivo互联网技术 微信公众号 链接: https://mp.weixin.qq.com/s/rSpWorfNTajtqq_pd7H-nw作者:悟空中台研发团队 一.背景 移动端网页的加载 ...

  6. TapTap 算法平台的 Serverless 探索之路

    分享人:陈欣昊,TapTap/IEM/AI平台负责人 摘要:本文主要介绍心动网络算法平台在Serverless上的实践. <TapTap算法平台的 Serverless 探索之路> Ser ...

  7. WebGPU光追引擎基础课系列目录

    大家好~我开设了"WebGPU光追引擎基础课"的线上课程,从0开始,在课上带领大家现场写代码,使用WebGPU开发基础的光线追踪引擎 课程重点在于基于GPU并行计算,实现BVH构建 ...

  8. JavaScrip基本语法

    2. 上篇内容回顾 1. CSS属性 1. 高和宽 2. 字体相关 3. 文本相关 4. 背景相关 1. background-color: red 2. background-image: url( ...

  9. nginx 负载均衡 proxy_pass 与 upstream 及 rewrite ,expires 的配置总结

    本文为博主原创,转载请注明出处: 先查看 一段 nginx 相关的配置: location /test/   {   set $arg_remote_addr $request_id; proxy_p ...

  10. 缓存选型:Redis or MemCache

    ★ Redis24篇集合 1 背景 互联网产品为了保证高性能和高可用性,经常会使用缓存来进行架构设计.最常用的就是使用Redis了,也有部分企业会选择使用Memcache. 所以了解 Redis 和 ...