1 solutions
-
0
C :
#include<stdio.h> #include<math.h> #define pi 3.141592653589793 double sqr(double x) { return x*x; } int main() { double x1,y1,x2,y2,x3,y3,a,b,c,r; while(scanf("%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3)!=EOF) { a=sqr(x1-x2)+sqr(y1-y2); b=sqr(x1-x3)+sqr(y1-y3); c=sqr(x2-x3)+sqr(y2-y3); r=sqrt(c/4/(1-sqr(a+b-c)/4/a/b)); printf("%.2lf\n",2*pi*r); } return 0; }C++ :
#include<stdio.h> #include<math.h> #define pi 3.141592653589793 double sqr(double x) { return x*x; } int main() { double x1,y1,x2,y2,x3,y3,a,b,c,r; while(scanf("%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3)!=EOF) { a=sqr(x1-x2)+sqr(y1-y2); b=sqr(x1-x3)+sqr(y1-y3); c=sqr(x2-x3)+sqr(y2-y3); r=sqrt(c/4/(1-sqr(a+b-c)/4/a/b)); printf("%.2lf\n",2*pi*r); } return 0; }Java :
import java.text.DecimalFormat; import java.util.Scanner; public class Main { private static Scanner s = new Scanner(System.in) ; private static double PI = 3.141592653589793 ; private static DecimalFormat df = new DecimalFormat("0.00") ; public static void main(String[] args) { while(s.hasNext()){ double x1 = s.nextDouble() ; double y1 = s.nextDouble() ; double x2 = s.nextDouble() ; double y2 = s.nextDouble() ; double x3 = s.nextDouble() ; double y3 = s.nextDouble() ; double d = 2*(x1-x2)*(y3-y2) - 2*(y1-y2)*(x3-x2) ; double d1 = (y3-y2)*(x1*x1+y1*y1-x2*x2-y2*y2) - (y1-y2)*(x3*x3+y3*y3-x2*x2-y2*y2); double d2 = (x1-x2)*(x3*x3+y3*y3-x2*x2-y2*y2) - (x3-x2)*(x1*x1+y1*y1-x2*x2-y2*y2); double x = d1/d ; double y = d2/d ; double R = Math.sqrt((x2-x)*(x2-x)+(y2-y)*(y2-y)) ; System.out.println(df.format(PI*R*2)); } } }
- 1
Information
- ID
- 20070
- Time
- 1000ms
- Memory
- 32MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By