POJ 2707 Copier Reduction
Time Limit: 1000MS
Memory Limit: 65536K
Total Submissions: 6700
Accepted: 3440
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 280
10 25 88 10
8 13 5 1
9 13 10 6
199 333 40 2
75 90 218 280
999 99 1 10
0 0 0 0
Sample Output
50%
100%
12%
66%
1%
100%
1%
Source
Mid-Central USA 2005
#include
void swap(int& a,int& b)
{
int t=a;a=b;b=t;
}
int main()
{
int a,b,c,d;
while(scanf("%d%d%d%d",&a,&b,&c,&d)!=EOF)
{
if(a==0&&b==0&&c==0&&d==0) break;
if(a if(c
int y=(int)((d*1.0/b)*100);
if(x>y) swap(x,y);
if(x>100) x=100;
printf("%d",x);
puts("%");
}
return 0;
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Java/PDF에서 이미지 바꾸기우리 모두 알다시피 PDF는 편집하기 어려운 일종의 문서 형식입니다. 그러나 다른 사람으로부터 PDF 문서를 받을 때 문서의 이미지를 새 이미지로 바꾸는 등 약간의 수정이 필요할 수 있습니다. 이 문서에서는 Java...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.