Submission #534995
Source Code Expand
#include <iostream> #include <algorithm> #include <string> #include <set> #include <vector> #include <queue> #include <tuple> #include <numeric> #include <sstream> #include <cassert> using namespace std; bool check(long double x, long double h, long double w) { long double a = h - sqrt(x*x - w*w); long double b = w - sqrt(x*x - h*h); if (a < 0 || b < 0) return false; long double y = sqrt(a*a + b*b); return y > x; } long double f(long double h, long double w) { long double lb = max(h, w), ub = sqrt(h*h + w*w); for (int i = 0; i < 100; ++i) { long double mid = (lb + ub)/2; if (check(mid, h, w)) lb = mid; else ub = mid; } return lb; } long double g(long double h, long double w) { return min(w*1.0, sqrt((w / 2)*(w / 2) + h*h)); } int main(){ cin.tie(0); ios::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(12); int t; cin >> t; while (t--) { int h, w; cin >> h >> w; cout << max({ check(f(h, w), h, w) ? f(h, w) : 0, g(h, w), g(w, h) }) << endl; } }
Submission Info
Submission Time | |
---|---|
Task | E - マッサージチェア2015 |
User | yuusti |
Language | C++11 (GCC 4.9.2) |
Score | 200 |
Code Size | 1056 Byte |
Status | AC |
Exec Time | 54 ms |
Memory | 1268 KB |
Judge Result
Set Name | All | ||
---|---|---|---|
Score / Max Score | 200 / 200 | ||
Status |
|
Set Name | Test Cases |
---|---|
All | 00_sample.txt, 10_squares.txt, 11_maxw.txt, 12_maxh.txt, 20_corner.txt, 21_corner.txt, 22_corner.txt, 23_corner.txt, 24_corner.txt, 30_small.txt, 40_random.txt, 41_random.txt, 42_random.txt, 50_corner.txt, 51_corner.txt, 52_corner.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_sample.txt | AC | 38 ms | 1144 KB |
10_squares.txt | AC | 54 ms | 1172 KB |
11_maxw.txt | AC | 45 ms | 1132 KB |
12_maxh.txt | AC | 44 ms | 1268 KB |
20_corner.txt | AC | 47 ms | 1208 KB |
21_corner.txt | AC | 47 ms | 1152 KB |
22_corner.txt | AC | 47 ms | 1088 KB |
23_corner.txt | AC | 47 ms | 1080 KB |
24_corner.txt | AC | 47 ms | 1140 KB |
30_small.txt | AC | 44 ms | 1140 KB |
40_random.txt | AC | 48 ms | 1144 KB |
41_random.txt | AC | 48 ms | 1076 KB |
42_random.txt | AC | 48 ms | 1140 KB |
50_corner.txt | AC | 50 ms | 1144 KB |
51_corner.txt | AC | 48 ms | 1144 KB |
52_corner.txt | AC | 49 ms | 1080 KB |