POJ 2707
来源:互联网 发布:网络安全法亮点解读 编辑:程序博客网 时间:2024/05/16 20:29
Description
What do you do if you need to copy a 560x400mm image onto a standard sheet of US letter-size paper (which is about 216x280mm), while keeping the image as large as possible? You can rotate the image 90 degrees (so that it is in "landscape" mode), then reduce it to 50% of its original size so that it is 200x280mm. Then it will fit on the paper without overlapping any edges. Your job is to solve this problem in general.
Input
The input consists of one or more test cases, each of which is a single line containing four positive integers A, B, C, and D, separated by a space, representing an AxBmm image and a CxDmm piece of paper. All inputs will be less than one thousand. Following the test cases is a line containing four zeros that signals the end of the input.
Output
For each test case, if the image fits on the sheet of paper without changing its size (but rotating it if necessary), then the output is 100%. If the image must be reduced in order to fit, the output is the largest integer percentage of its original size that will fit (rotating it if necessary). Output the percentage exactly as shown in the examples below. You can assume that no image will need to be reduced to less than 1% of its original size, so the answer will always be an integer percentage between 1% and 100%, inclusive.
Sample Input
560 400 218 28010 25 88 108 13 5 19 13 10 6199 333 40 275 90 218 280999 99 1 100 0 0 0
Sample Output
50%100%12%66%1%100%1%
POJ水题,注意定义a,b,c,d为float型。关于到精度之类,一定注意int float 区别。
#include<iostream>using namespace std;void max(float&a,float&b){ float t; if(a<b) { t=a; a=b; b=t; }}int main(){ while(1) { float a,b,c,d,i; cin>>a>>b>>c>>d; if(a==0&&b==0&&c==0&&d==0) return 0; else { max(a,b); max(c,d); for( i=100;i>0;i--) { if((a*i/100<=c)&&(b*i/100<=d)) break ; } cout<<i<<"%"<<endl; } } return 0;}
0 0
- POJ 2707
- poj-2707
- POJ 2707 Copier Reduction
- POJ 2707 水题,输入输出
- poj 2707 Copier Reduction
- Poj 2707 Copier Reduction
- POJ
- poj
- POJ
- POJ
- poj
- poj
- POJ
- POJ
- poj
- POJ
- POJ
- POJ
- Objective-c小结
- Myeclipse10等各种版本破解(Blue版也可破解)
- 数据库开发经典总结
- 程序员的自我修养
- VC++窗口任意分割
- POJ 2707
- OpenMP to GPGPU:一种实现自动翻译和调优的编译框架[1]
- 工作心得
- Mac上安装MySql与简单配置
- android中的ellipsize
- Android复习之切换图片ImageSwitcher&Gallery
- 函数对象
- 黑马程序员—Java语言基础(Function函数)
- CodingTrip - 携程编程大赛 (预赛第二场)——位图像素的颜色