| Problem | Verdict | Lang | Time | Best | Rank | Submit Time |
|---|---|---|---|---|---|---|
| discuss438 - | Accepted | C++11 | 0.000 | 0.000 | 2662 | 3 mins ago |
#include <bits/stdc++.h>
using namespace std;
double sqr(double x){
return x*x;
}
double sqrt(double x){
return pow(x, 1.0/2);
}
int main() {
double xa, ya, xb, yb, xc, yc;
while(cin >> xa >> ya >> xb >> yb >> xc >> yc){
double ab = sqrt(sqr(xb-xa)+sqr(yb-ya));
double bc = sqrt(sqr(xc-xb)+sqr(yc-yb));
double ac = sqrt(sqr(xc-xa)+sqr(yc-ya));
double p = (ab + bc + ac) / 2;
double s = sqrt(p*(p-ab)*(p-bc)*(p-ac));
double r = ab*bc*ac / (4*s);
cout<<fixed<<setprecision(2)<<3.141592653589793*2*r<<"\n";
}
}
Function Definitions:
double sqr(double x): Defines a function to compute the square of a given double value.double sqrt(double x): Defines a function to compute the square root of a given double value using thepowfunction.
Main Function:
- Declares six variables
xa,ya,xb,yb,xc,ycto store the coordinates of three points.
- Declares six variables
While Loop:
- Uses a while loop that reads input for the coordinates of three points until it reaches the end of the input.
- Inside the loop, it calculates the distances
ab,bc, andacbetween the points using the distance formula.
Circumference Calculation:
- Calculates the semi-perimeter
pusing the formula: . - Calculates the area
sof the triangle using Heron's formula: . - Computes the radius
rof the circumcircle using the formula: . - Finally, calculates the circumference of the circumcircle and outputs it with fixed precision.
- Calculates the semi-perimeter

No comments:
Post a Comment