Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define pi acos(-1.0)
- double R,x1,x2,y;
- double getArea(double r,double x1,double x2){
- double cos2 = acos(x2*1.0/R);
- double cos1 = acos(x1*1.0/R);
- double res = R*(x2*sin(cos2) - x1*sin(cos1));
- double tom = res - R*R*cos2 + R*R*cos1;
- return tom;
- }
- void solve1(){
- double oditi,sam,ron,tom;
- if(x1>=R){
- oditi = pi*R*R;
- tom = 0;
- double brothersArea = abs(x2-x1)*y*2.0;
- sam = ron = brothersArea/2.0;
- }else if(x2>=R){
- tom = getArea(R,x1,R);
- oditi = pi*R*R - tom;
- double brothersArea = abs(x2-x1)*y*2.0 - tom;
- sam = ron = brothersArea/2.0;
- }else{
- tom = getArea(R,x1,x2);
- oditi = pi*R*R - tom;
- double brothersArea = abs(x2-x1)*y*2.0 - tom;
- sam = ron = brothersArea/2.0;
- }
- printf("%.3lf %.3lf %.3lf %.3lf\n",oditi,sam,ron,tom);
- }
- int main(){
- int nCase;
- scanf("%d",&nCase);
- for(int cs = 1;cs<=nCase;cs++){
- scanf("%lf %lf %lf %lf",&R,&x1,&x2,&y);
- if(x1>x2) swap(x1,x2);
- solve1();
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment