Problem A. Alex Origami Squares
Input file: alex.in
Output file: alex.out
Time limit: 2 seconds
Memory limit: 256 megabytes
Alex is fond of origami — Japanese art of paper folding. Most origami designs start with a square sheet
of paper. Alex is going to make a present for his mother. Present’s design requires three equal square
sheets of paper, but Alex has only one rectangular sheet. He is able to cut out squares of this sheet, but
their sides should be parallel to the sides of the sheet. Help Alex to determine the maximum possible
size of the paper squares he is able to cut out.
Input
The single line of the input file contains two integers h and w — the height and the width of the sheet
of paper (1 ≤ h, w ≤ 1000).
Output
Output a single real number — the maximum possible length of the square side. It should be possible
to cut out three such squares of h × w sheet of paper, so that their sides are parallel to the sides of the
sheet.
Your answer should be precise up to three digits after the decimal point.
Examples
alex.in alex.out
210 297 105.0
250 100 83.333333
#include <iostream>
#include <stdio.h>
#include<string.h>
#include<stdlib.h>
#include <algorithm>
using namespace std;
int main()
{
double h, w ;
freopen("alex.in","r",stdin);
freopen("alex.out","w",stdout);
cin >> h>> w;
if(h<w)
{
double t=h;
h=w;
w=t;
}
double max1=w/2.000;
if(w<=h/3.000)
max1=max(max1,w/1.000);
else
max1 = max(max1,h/3.000);
printf("%.3lf\n",max1);
return 0;
}