#include using namespace std; constexpr long double PI = 3.1415926535897932384626433; //Euclidean distance template T EucDist(T x1, T y1, T x2, T y2) { return sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2)); } int main() { double r,R,ok = 180., ng = 360., md,x,y,d; assert(0> r >> R; for(int i = 0; i < 10000; ++i){ md = (ok+ng)/2.; x = R*cos(md/180.*PI); y = R*sin(md/180.*PI); d = EucDist(x,y,R,0.); (2*r<=d?ok:ng)=md; } double area = PI*((R+r)*(R+r)-(R-r)*(R-r))*ok/360. + PI*r*r; double t = PI*ok/180.; printf("%.5f\n",t); printf("%.5f\n",area); }