[NWRRC2015] Alex Origami Squares(浮点数二分)

题面翻译

题目描述

有一张矩形纸,要求将其裁成三个全等的正方形,且每一个正方形的侧面都与纸张的侧面平行,问裁成的小正方形边长最大是多少。

输入格式

一行两个整数 h h h w w w ( 1 ≤ h , w ≤ 1 0 3 ) (1\le h,w\le 10^3) (1h,w103) 表示矩形纸张的长和宽。

输出格式

输出一行一个实数,表示正方形边长的最大可能值。

你的答案与标准答案的相对及绝对误差不应超过 1 0 − 3 10^{-3} 103

题目描述

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.

输入格式

The single line of the input file contains two integers h h h and w w w – the height and the width of the sheet of paper ( 1 ≤ h , w ≤ 1000 ) (1 \le h , w \le 1000) (1h,w1000) .

输出格式

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 h \times w 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.

样例 #1

样例输入 #1

210 297

样例输出 #1

105.0

样例 #2

样例输入 #2

250 100

样例输出 #2

83.333333

提示

Time limit: 2 s, Memory limit: 256 MB.

spj provider:@shenyouran.

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define inf 1e18
const int mod=1e9+7;
const int N=2e5+5;
void solve(){
	int x,y;
	cin>>x>>y;
	int a=max(x,y);
	int b=min(x,y);
	double l=0,r=1e9;
	while((r-l)>1e-3){
		double mid=(r+l)/2;
		if(mid*3<=a&&mid<=b||mid*2<=a&&mid*2<=b) l=mid;
		else r=mid;
	}
	printf("%lf",l);
}
signed main(){
//	ios::sync_with_stdio(false);
//	cin.tie(nullptr);
//	cout.tie(nullptr);
	int tt=1;
//	cin>>tt;
	while(tt--) solve();
	return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值