Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- //#pragma GCC optimize("unroll-loops")
- //#pragma GCC optimize("Ofast")
- //#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
- //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
- #define F first
- #define S second
- #define pb push_back
- #define ll long long
- #define ld long double
- #define endl '\n'
- #define pii pair <int, int>
- #define pll pair <ll, ll>
- #define pld pair <ld, ld>
- using namespace std;
- const int N = 1e3 + 5;
- int main() {
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- #ifdef LOCAL
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- #else
- freopen("garden.in", "r", stdin);
- freopen("garden.out", "w", stdout);
- #endif
- int x, y;
- cin >> x >> y;
- x = abs(x);
- y = abs(y);
- if (!((x % 2 && y % 2) || (x % 4 == 0 && y % 4 == 0))) {
- cout << -1;
- return 0;
- }
- int k1 = x / 4;
- int k2 = y / 4;
- ld ans = 0;
- ans += (2 * sqrt(2) + 4) * min(k1, k2);
- x -= min(k1, k2) * 4;
- y -= min(k1, k2) * 4;
- if (x < y) {
- swap(x, y);
- }
- if (y == 3) ans += 2;
- ans += (x / 4) * (2 + 2 * sqrt(2));
- x %= 4;
- if (x == 1) ans += sqrt(2);
- if (x == 3) ans += sqrt(2) + 2;
- cout << fixed << setprecision(10) << ans;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement