#include #define cerr if(0) cout using namespace std; using LL = long long; using LD = long double; using PLD = pair; using PLL = pair; const LD PI = acosl(-1); template T dotProduct(paira, pair b) { return a.first * b.first + a.second * b.second; } template T crossProduct(paira, pair b) { return a.first * b.second - a.second * b.first; } template T lengthPow(paira) { return dotProduct(a,a); } template LD length(paira) { return sqrtl(lengthPow(a)); } template pair operator+(paira, pair b) { T x =a.first + b.first; T y =a.second + b.second; return {x,y}; } template pair operator-(paira, pair b) { T x =a.first - b.first; T y =a.second - b.second; return {x,y}; } template pair operator*(paira, T b) { T x =a.first *b; T y =a.second * b; return {x,y}; } template pair operator/(paira, T b) { T x =a.first / b; T y =a.second / b; return {x,y}; } LL pointLineDistance (PLL p, PLL a, PLL dir) { return abs(crossProduct(p-a,dir)); } pair > circleLine(PLL o, LL r, PLL a, PLL dir) { auto vec = a- o; if(pointLineDistance(o,a,dir) >= r) { return {false, {PLD{0,0}, PLD{0,0}}}; } LL x = vec.first; LL y = vec.second; LL D = dir.first; LL K = dir.second; LD root = r*r*K*K - x*x*K*K + 2*D*x*y*K + D*D*r*r - D*D*y*y; root = sqrtl(root); LD t1 = (-D*x - y*K + root) / (D*D + K*K); LD t2 = (-D*x - y*K - root) / (D*D + K*K); if(t1 > t2) swap(t1,t2); PLD res1 = PLD{a} + PLD{dir} * t1; PLD res2 = PLD{a} + PLD{dir} * t2; return {true, {res1,res2}}; } bool inCircle(PLL p, PLL o, LL r) { return lengthPow(p-o) < r*r; } LD area( PLD a, PLD b, PLL o, LL r) { LD dl = lengthPow(a-b); LD angle = (2 * r * r - dl) / (2 * r * r); angle = acosl(angle); LD areaO = abs(PI * r*r * angle / (2 * PI)); LD areaT = r * r * sin(angle) / 2; return areaO - areaT; } LD area(const vector& vec) { LD res = 0; for(int i = 2; i < vec.size(); ++i) { PLD a = vec[i] - vec[0]; PLD b= vec[i-1] - vec[0]; res += crossProduct(a, b); } return abs(res)/2.0; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout<>Ox>>Oy>>r; int a, bb, c, d; cin>> a >> bb >> c >> d; int t1 = min(a,c); int t2 = min(bb,d); int x = max(a,c) - t1; int y = max(bb,d) - t2; Ox -= t1; Oy -= t2; cerr< points = {PLL{0,0}, PLL{0,y}, PLL{x,y}, PLL{x,0}}; auto r1 = circleLine(O,r, points[0], {0,1}); auto r2 = circleLine(O,r, points[1], {1,0}); auto r3 = circleLine(O,r, points[2], {0,-1}); auto r4 = circleLine(O,r, points[3], {-1,0}); array,4> b; if(r1.first) { PLD v1 = r1.second.first; PLD v2 = r1.second.second; if(v1.second >= 0 && v1.second <= y) { b[0].push_back({0,v1.second}); } if(v2.second >= 0 && v2.second <= y) { b[0].push_back({0,v2.second}); } } if(r2.first) { PLD v1 = r2.second.first; PLD v2 = r2.second.second; if(v1.first >= 0 && v1.first <= x) { b[1].push_back({v1.first, y}); } if(v2.first >= 0 && v2.first <= x) { b[1].push_back({v2.first, y}); } } if(r3.first) { PLD v1 = r3.second.first; PLD v2 = r3.second.second; if(v1.second >= 0 && v1.second <= y) { b[2].push_back({x,v1.second}); } if(v2.second >= 0 && v2.second <= y) { b[2].push_back({x,v2.second}); } } if(r4.first) { PLD v1 = r4.second.first; PLD v2 = r4.second.second; if(v1.first >= 0 && v1.first <= x) { b[3].push_back({v1.first, 0}); } if(v2.first >= 0 && v2.first <= x) { b[3].push_back({v2.first, 0}); } } if(0 < Ox && Ox < x && 0 < Oy && Oy < y) { cerr<<"w srodku\n"; LD res = 0; for(int i = 0; i < 4; ++i) { if(b[i].empty()) continue; for(int j = 1; j < 4; ++j) { int nex =(i+j)%4; if(!b[nex].empty()) { if(!inCircle(points[nex], O,r)) res += area(b[i].back(), b[nex].front(), O , r); break; } } } cerr< poly; for(int i = 0; i < 4; ++i) { if(inCircle(points[i], O,r)) poly.push_back(points[i]); for(auto u : b[i]) poly.push_back(u); } res += area(poly); cout << res << "\n"; } else { cerr<<"out\n"; LD res = 0; for(int i = 0; i < 4; ++i) { if(b[i].empty()) continue; for(int j = 1; j < 4; ++j) { int nex =(i+j)%4; if(!b[nex].empty()) { cerr<<"check "<< i << ' '< poly; for(int i = 0; i < 4; ++i) { if(inCircle(points[i], O,r)) poly.push_back(points[i]); for(auto u : b[i]) poly.push_back(u); } cerr<