题目简述

有两个矩形,大小分别是 \(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. 信创就用国产的生态,Solon v2.6.4 发布

    Solon 是什么框架? Java 新的"生态级"应用开发框架.从零开始构建,有自己的标准规范与开放生态(历时六年,具备全球第二级别的生态规模). 相对于 Spring,有什么特点 ...

  2. ElasticSearch 实现分词全文检索 - Java SpringBoot ES 索引操作

    目录 ElasticSearch 实现分词全文检索 - 概述 ElasticSearch 实现分词全文检索 - ES.Kibana.IK安装 ElasticSearch 实现分词全文检索 - Rest ...

  3. Java 项目工程搭建 --创建子模块(Spring Initializr)

    一下篇,常用 Java 项目工程搭建 --创建子模块(依赖父工程)   也不算常用,常用的是 ctrl+c.ctrl+v  ,哈哈 Package要手动改下,生成的很丑 选能支持 Alibaba Cl ...

  4. 让 ChatGPT 如虎添翼 2.0

    月初写了4个工具,让 ChatGPT 如虎添翼!,时隔二十多天,我又发现了基于ChatGPT的应用,只推最好用的,强烈建议大家都感受一下. 极简搭建 ChatGPT 演示网页 项目地址:https:/ ...

  5. WebSoket 的广泛应用

    目前大多数网站都在使用的传统 HTTP 协议,即由 Web 服务器通过 HTTP 接收并响应来自客户端的消息,整个发起请求与响应的过程类似我们点外卖,由以下 2 部分构成: 下订单(发起请求):用户( ...

  6. 【库函数】Qt中Json的操作

    参考博客: https://blog.csdn.net/hp_cpp/article/details/80338116 从文件中读取json https://www.cnblogs.com/ybqjy ...

  7. Codeforces Round #629 (Div. 3) & 19级暑假第六场训练赛

    A:Codeforces 1328A Divisibility Problem 整除+模 Input 5 10 4 13 9 100 13 123 456 92 46 Output 2 5 4 333 ...

  8. 五、java操作redis

    系列导航 一.redis单例安装(linux) 二.redis主从环境搭建 三.redis集群搭建 四.redis增加密码验证 五.java操作redis --demo主方法 package com. ...

  9. vue prop 会接收不同的数据类型

    refAge: { type: Number, default: 0 }, refName: { type: String, default: '' }, hotDataLoading: { type ...

  10. freeswitch新增模块APP

    概述 之前的文章中,我们讲解了freeswitch的源码基本结构,如何新增一个插件式模块,以及如何在模块中新增一个命令式API接口. freeswitch的架构非常适合这种业务开发模式,即以frees ...