Thursday, 4 February 2021

Circle in Square Lightoj 1022

 The equation used in this problem is:

Shaded area= area of the Square - Area of the circle

#include<iomanip>
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    int t,i;
    cin>>t;
    for(i=1;i<=t;i++){
        double r,pi,ca,sa,ra;
        cin>>r;
        pi=2*acos(0.0);
       ca=pi*(r*r);
       sa=(2*r)*(2*r);
       ra=sa-ca;
        cout<<"Case "<<i<<": "<<fixed<<setprecision(2)<<ra<<endl;
}
    return 0;
}

No comments:

Post a Comment

If you have any doubts, let me know through comments

Monkey Banana Problem lightoj 1004

  In this problem we will check which adjacent cell will benefits the monkey best. For this, we will check all possible solution of this pro...