题目:给你很多张矩形的纸,问哪张可以剪下四个面积相同的最大的正方形。
分析:简单题。只有两种减法:1.剪成2*2的;2.剪成1*4的。
注意:计算后的正方形边长可能是小数,例如:2*2的比3*3的小,要用浮点型处理。
#include <iostream>
#include <cstdlib>
#include <cstdio>
using namespace std;
double value( int h, int w )
{
if ( h < w ) swap( h, w );
return max( w/2.0, min( h/4.0, w+0.0 ) );
}
int main()
{
int n;
int h,w;
while ( ~scanf("%d",&n) && n ) {
double max = 0,now = 1;
for ( int i = 1 ; i <= n ; ++ i ) {
scanf("%d%d",&h,&w);
if ( max < value( h, w ) ) {
max = value( h, w );
now = i;
}
}
printf("%.0lf\n",now);
}
return 0;
}
分享到:
相关推荐
unity幸运转盘代码,有美术资源,有源码,
语言:English (United States) 对于有障碍,阅读,焦点和注意力困难,Omoguru发出清晰可理解的文字。 ------**我们想改善延期,您可以帮助我们。继续支持,让我们了解您的经验和建议。如果您喜欢延期,请向我们留下...
这本书比较新,还没有来得及看,有需要的自行拿去。。
The easiest way to get started with PostgreSQL on the Mac.zip,在Mac上开始使用PostgreSQL的最简单方法
Python Machine Learning By Example -- The easiest way to get into machine learning -- Code
It’s making waves everywhere from mainstream media to the actual space flight industry, but it has a bit of a learning curve. In this book, five KSP nerds—including an astrophysicist—teach you ...
用pytorch写FCN进行手提包的语义分割。用pytorch写FCN进行手提包的语义分割。用pytorch写FCN进行手提包的语义分割。
使用python语言和pytorch框架实现FCN
使用C#制作飞扬的小鸟游戏的最简单方法。
This book provides the easiest way to learn Java Programming. It features concepts of Java Programming with simple examples. All difficult concepts are handled with simple and easy to understand ...
MLPickerScrollViewIntroduction:The easiest way to use PickerScrollView这是一个对横向滚动选择器的自定义UI控件,只要几行代码就可以集成类似横向滚动中间放大的效果并且选中的功能。Presentation:模拟场景<...
乐鑫官方工具链 The easiest way to install ESP-IDF’s prerequisites is to download the ESP-IDF Tools installer from this URL: https://dl.espressif.com/dl/esp-idf-tools-setup-2.2.exe The installer...
Wubi是Windows用户的官方受支持的Ubuntu安装程序,只需单击即可将您带入Linux世界。 该网站已移至http://www.ubuntu.com/desktop/get-ubuntu/windows-installer,您可以在其中找到最新版本。
The Fastest and Easiest Way for Beginners to Develop Android Apps What’s Stopping You From Making Your Own Android Apps? The mobile phone app market is worth more than $25 billion and is expected ...
esrgan算法的研究,通过esrgan对图片进行超分辨率
matlab form useful for making large forms in the easiest way possible
Unity优质资源Unity优质资源Unity优质资源Unity优质资源Unity优质资源Unity优质资源Unity优质资源Unity优质资源Unity优质资源Unity优质资源Unity优质资源Unity优质资源Unity优质资源Unity优质资源Unity优质资源Unity...
The easiest way to get going with the imagerotator is by copy-pasting the source code of this page to your site. Also make sure to copy-paste the .swf, .js and .xml file to your website. Plus your ...