博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
F - The Circumference of the Circle
阅读量:5992 次
发布时间:2019-06-20

本文共 2143 字,大约阅读时间需要 7 分钟。

Description

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

The input 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

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
#include 
#include
#include
using namespace std;#define PI 3.141592653589793int main(){ double x1,y1,x2,y2,x3,y3; while(cin>>x1>>y1>>x2>>y2>>x3>>y3){ double l,a1,b1,a2,b2,k1,k2,a,b; a1=x1/2+x2/2; a2=x1/2+x3/2; b1=y1/2+y2/2; b2=y1/2+y3/2; if(y1!=y2&&y3!=y1){ k1=(x1-x2)/(y2-y1); k2=(x1-x3)/(y3-y1); a=(k1*a1-k2*a2+b2-b1)/(k1-k2); b=k1*(a-a1)+b1; } else if(y1==y2){ k2=(x1-x3)/(y3-y1); a=(x1+x2)/2; b=k2*(a-a2)+b2; } else { k1=(x1-x2)/(y2-y1); a=(x1+x3)/2; b=k1*(a-a1)+b1; } l=2*PI*sqrt((a-x1)*(a-x1)+(b-y1)*(b-y1)); cout.precision(2); cout.setf(ios::fixed); cout<
<

 

转载于:https://www.cnblogs.com/farewell-farewell/p/5184095.html

你可能感兴趣的文章
iOS-- 快速集成iOS基于RTMP的视频推流
查看>>
BZOJ1497: [NOI2006]最大获利[最小割 最大闭合子图]
查看>>
jQuery 效果 - 隐藏和显示
查看>>
Chapter 2 Open Book——31
查看>>
Ansible4:Ad-hoc与命令执行模块【转】
查看>>
纯css3圆形从中心向四周扩散动画效果
查看>>
eclipse里maven install时,报错提示jdk为无效的目标版本:1.7
查看>>
继续Django
查看>>
使用Ecplise git commit时出现"There are no stages files"
查看>>
Linux中变量#,#,@,0,0,1,2,2,*,$$,$?的含义
查看>>
RMAN的恢复篇
查看>>
windows环境下sublime的nodejs插件详细安装图解
查看>>
(转)PLSQL Developer导入Excel数据
查看>>
libsvm下的windows版本中的工具的使用
查看>>
windows系统中软件开发常用的软件
查看>>
Android 5.0之后屏幕截图的方法
查看>>
(二)Lua脚本语言入门(关于函数)
查看>>
java---servlet与filter的联系与区别
查看>>
一句话说清楚cache和buffer
查看>>
C语言 · 核桃的数量
查看>>