To calculate the circumference of a circle seems to be an easy task - provided you know its diameter. But what if you don't?
You are given the cartesian coordinates of three non-collinear points in the plane.
Your job is to calculate the circumference of the unique circle that intersects all three points.
Input Specification
The input file will contain one or more test cases. Each test case consists of one line containing six real numbers x1,y1, x2,y2,x3,y3, representing the coordinates of the three points. The diameter of the circle determined by the three points will never exceed a million. Input is terminated by end of file.
Output Specification
For each test case, print one line containing one real number telling the circumference of the circle determined by the three points. The circumference is to be printed accurately rounded to two decimals. The value of pi is approximately 3.141592653589793.
Sample Input
0.0 -0.5 0.5 0.0 0.0 0.50.0 0.0 0.0 1.0 1.0 1.05.0 5.0 5.0 7.0 4.0 6.00.0 0.0 -1.0 7.0 7.0 7.050.0 50.0 50.0 70.0 40.0 60.00.0 0.0 10.0 0.0 20.0 1.00.0 -500000.0 500000.0 0.0 0.0 500000.0
Sample Output
3.144.446.2831.4262.83632.243141592.65
code:
#include<stdio.h>
#include<math.h>
struct Point{
double x;
double y;
}a[3];
double SinA(){
double dist,high;
double A,B,C;
A = a[0].y-a[1].y;
B = a[1].x-a[0].x;
C = a[0].x*a[1].y-a[1].x*a[0].y;
high = fabs(A*a[2].x+B*a[2].y+C)/sqrt(A*A+B*B);
dist = sqrt(pow((a[0].x - a[2].x),2)+pow(a[0].y-a[2].y,2));
return high/dist;
}
int main(){
double c,ab;
while(scanf("%lf%lf%lf%lf%lf%lf",&a[0].x,&a[0].y,&a[1].x,&a[1].y,&a[2].x,&a[2].y)!=EOF){
ab = sqrt(pow((a[1].x - a[2].x),2)+pow(a[1].y-a[2].y,2));
c = ab * 3.141592653589793 / SinA();
printf("%.2lf\n",c);
}
return 0;
}
分享到:
相关推荐
【标题】"joj acm 部分习题解答"揭示了这是一份与JOJ(Judge Online Job)和ACM(国际大学生程序设计竞赛)相关的资源,主要是作者对于某些题目的解题思路和代码实现。JOJ是用于在线评测编程竞赛题目的一种平台,而...
描述中提到的"joj acm 源代码",JOJ(Judge Online Judge)是一个在线编程评测系统,很多高校和编程爱好者使用它来提交和测试代码,解决各种算法问题。源代码通常是程序员编写的原始程序,这里指的可能是参赛者在ACM...
【标题】:“JOJ上做的一些ACM试题” 在计算机科学领域,ACM(Association for Computing Machinery)国际大学生程序设计竞赛是一项备受瞩目的比赛,旨在提升大学生的算法设计、问题解决以及团队协作能力。JOJ...
【标题】"JOJ-jilin-university--acm.rar_joj" 提供的是吉林大学JOJ在线判题系统的编程竞赛代码集,主要用于帮助初学者入门。 【描述】中的信息表明,这个压缩包内的代码样例是专门为在JOJ平台上进行编程训练的学生...
#### 标题:吉林大学ACM题集.pdf—JOJ 此文档标题明确指出了文档的主要内容——一个由吉林大学组织编写的ACM竞赛题集,并且该题集是以PDF格式提供的。这里提到的“JOJ”即吉林大学在线裁判系统(Jilin University On...
joj 部分题目答案 自己做的 仅供参考 joj 部分题目答案 自己做的 仅供参考 joj 部分题目答案 自己做的 仅供参考 joj 部分题目答案 自己做的 仅供参考 joj 部分题目答案 自己做的 仅供参考
根据给定的信息,本文将详细解释“acm joj 1600”中的两种大数取模运算方法。此问题主要关注如何高效地计算形如 \(a^b \mod m\) 的表达式,这对于处理大数据或进行密码学运算非常重要。 ### 大数取模运算 #### ...
吉林大学 joj 1000-2645题代码,嘿嘿,大家就不用在花JPOINT买代码了,祝ACMer实现自己的心愿