Alex Origami Squares Gym 100801A

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;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值