题目简述

有两个矩形,大小分别是 \(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. 从“概念”到“应用”,字节跳动基于 DataLeap 的 DataOps 实践

    更多技术交流.求职机会,欢迎关注字节跳动数据平台微信公众号,回复[1]进入官方交流群 近日,火山引擎数智平台 VeDI Meetup「超话数据」在深圳举办,来自火山引擎的产品专家分享了字节跳动基于 D ...

  2. 如何在NET 6.0使用结构化的日志系统

              在我们的系统里面,有一项技术是必须使用的,那就是日志记录.我们在调试系统或者跟踪系统运行情况,都可以通过日志了解具体的情况.在项目开发中,我们有可能使用系统本身所带的日志系统,也有 ...

  3. Profile Config 多环境不同配置

    应用场景如:我们可以在开发.测试环境中,启用 Swagger,在生产环境中不启用 package com.vipsoft.web.boot.config; import springfox.docum ...

  4. ubuntu下完全卸载重装docker教程

    操作需在管理员权限下运行 卸载docker 1.删除docker的所有包 apt-get autoremove docker docker-ce docker-engine docker.io con ...

  5. 最火前端Web组态软件(可视化)

    ​ 友情提示:本文为原创文章,转载请注明出处,商务合作请私信!!! 前言: 随着物联网.大数据等技术高速发展,我们逐步向数字化.可视化的人工智能(AI)时代的方向不断迈进.智能时代是工业 4.0 时代 ...

  6. Find (and kill) process locking port 9000 on Mac

    You can try netstat netstat -vanp tcp | grep 9000 For macOS El Capitan and newer (or if your netstat ...

  7. 第六届蓝桥杯C++A组 A~F题题解

    蓝桥杯历年国赛真题汇总:Here 1.方格填数 在2行5列的格子中填入1到10的数字. 要求: 相邻的格子中的数,右边的大于左边的,下边的大于上边的. 如[图1.png]所示的2种,就是合格的填法. ...

  8. Windows 系统如何完全卸载 VSCode

    0. 参考资料 Uninstall visual studio code in windows 1. 删不干净的用户数据 最近正在从 Sublime Text 3 环境切换到 VS Code,看重的是 ...

  9. 文心一言 VS 讯飞星火 VS chatgpt (181)-- 算法导论13.4 4题

    四.用go语言,在 RB-DELETE-FIXUP 代码的哪些行中,可能会检查或修改哨兵 T.nil ? 文心一言: RB-DELETE-FIXUP 是红黑树中的一个操作,用于在删除一个节点后进行必要 ...

  10. 硬核调试实操 | 手把手带你实现 Serverless 断点调试

    导读:在应用开发过程中,或者开发完成后,若出现执行结果不符合我们的预期时,通常需要进行一定的调试工作.但是在 Serverless 架构下,调试工作往往会受到一些环境因素限制,如所开发的应用在本地是比 ...