Problem link:[http://lightoj.com/volume_showproblem.php?problem=1433]
Catagory: Adhoc, Mathematics
Explanation:
S=r*s
here,
S= Arc length between 2 points in circle
r= radius of circle
s= Angle between 2 points in circle
again,
c^2=a^2 + b ^2 - 2abcos(angle)
here, a=b=r
and c=distace between 2 points
Code:
#include<bits/stdc++.h>
#define ll long long int
#define SIZE 100005
using namespace std;
double dis(ll x1, ll x2, ll y1, ll y2)
{
double m=(x1-x2)*(x1-x2);
double n=(y1-y2)*(y1-y2);
return sqrt(m+n);
}
int main()
{
ll o1,o2,a1,a2,b1,b2,l;
cin>>l;
ll i=1;
while(i<=l)
{
cin>>o1>>o2>>a1>>a2>>b1>>b2;
double r=dis(o1,a1,o2,a2);
double d=dis(a1,b1,a2,b2);
double s=acos((2*r*r-d*d)/(2*r*r));
cout<<"Case "<<i<<": "<<fixed<<setprecision(8)<<r*s<<"\n";
i++;
}
return 0;
}
Catagory: Adhoc, Mathematics
Explanation:
S=r*s
here,
S= Arc length between 2 points in circle
r= radius of circle
s= Angle between 2 points in circle
again,
c^2=a^2 + b ^2 - 2abcos(angle)
here, a=b=r
and c=distace between 2 points
so, angle=Inverse_cos((2r^2-c^2)/r^2)
Code:
#include<bits/stdc++.h>
#define ll long long int
#define SIZE 100005
using namespace std;
double dis(ll x1, ll x2, ll y1, ll y2)
{
double m=(x1-x2)*(x1-x2);
double n=(y1-y2)*(y1-y2);
return sqrt(m+n);
}
int main()
{
ll o1,o2,a1,a2,b1,b2,l;
cin>>l;
ll i=1;
while(i<=l)
{
cin>>o1>>o2>>a1>>a2>>b1>>b2;
double r=dis(o1,a1,o2,a2);
double d=dis(a1,b1,a2,b2);
double s=acos((2*r*r-d*d)/(2*r*r));
cout<<"Case "<<i<<": "<<fixed<<setprecision(8)<<r*s<<"\n";
i++;
}
return 0;
}