Submission #534635
Source Code Expand
// Enjoy your stay. #include <bits/stdc++.h> #define long long long #define LOOPVAR_TYPE long #define all(x) (x).begin(), (x).end() #define sz(x) ((LOOPVAR_TYPE)(x).size()) #define foreach(it, X) for(__typeof((X).begin()) it = (X).begin(); it != (X).end(); it++) #define GET_MACRO(_1, _2, _3, NAME, ...) NAME #define _rep(i, n) _rep2(i, 0, n) #define _rep2(i, a, b) for(LOOPVAR_TYPE i = (LOOPVAR_TYPE)(a); i < (LOOPVAR_TYPE)(b); i++) #define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__) #define fir first #define sec second #define mp make_pair #define mt make_tuple #define pb push_back #define eb emplace_back const double EPS = 1e-9; const double PI = acos(-1.0); const long INF = 1070000000LL; const long MOD = 1000000007LL; using namespace std; typedef istringstream iss; typedef stringstream sst; typedef pair<LOOPVAR_TYPE, LOOPVAR_TYPE> pi; typedef vector<LOOPVAR_TYPE> vi; double H, W; typedef complex<double> P; void main2(){ if(H > W) swap(H, W); double l = sqrt(H*H + (W/2)*(W/2)); if(l <= W){ cout << l << endl; return; } double lo = 0, hi = W; rep(_, 100){ double mi = (lo + hi) / 2; P l = P(mi, -H); l *= P(0, 1); l *= sqrt(3) / 2; P m = P(mi / 2, -H / 2); P p = m + l; (p.real() <= W && p.imag() <= 0 ? lo : hi) = mi; } cout << sqrt(H*H + lo*lo) << endl; } int main(){ cin.tie(NULL); ios_base::sync_with_stdio(false); int T; cin >> T; cout << setprecision(16); while(T--){ cin >> H >> W; main2(); } }
Submission Info
Submission Time | |
---|---|
Task | E - マッサージチェア2015 |
User | evima |
Language | C++11 (GCC 4.9.2) |
Score | 200 |
Code Size | 1548 Byte |
Status | AC |
Exec Time | 43 ms |
Memory | 920 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 | 27 ms | 808 KB |
10_squares.txt | AC | 41 ms | 920 KB |
11_maxw.txt | AC | 35 ms | 916 KB |
12_maxh.txt | AC | 37 ms | 800 KB |
20_corner.txt | AC | 36 ms | 740 KB |
21_corner.txt | AC | 38 ms | 800 KB |
22_corner.txt | AC | 36 ms | 736 KB |
23_corner.txt | AC | 37 ms | 792 KB |
24_corner.txt | AC | 38 ms | 804 KB |
30_small.txt | AC | 34 ms | 800 KB |
40_random.txt | AC | 35 ms | 788 KB |
41_random.txt | AC | 36 ms | 708 KB |
42_random.txt | AC | 35 ms | 764 KB |
50_corner.txt | AC | 36 ms | 920 KB |
51_corner.txt | AC | 36 ms | 920 KB |
52_corner.txt | AC | 43 ms | 920 KB |