POJ 2242 The Circumference of the Circle
做题回顾:用到海伦公式,还有注意数据类型,最好统一
p=(a+b+c)/2;
s=sqrt(p*(p-a)*(p-b)*(p-c));//三角形面积,海伦公式
r=a*b*c/(4*s);//这是外接圆的半径
/*
Sample Input
0.0 -0.5 0.5 0.0 0.0 0.5
0.0 0.0 0.0 1.0 1.0 1.0
5.0 5.0 5.0 7.0 4.0 6.0
0.0 0.0 -1.0 7.0 7.0 7.0
50.0 50.0 50.0 70.0 40.0 60.0
0.0 0.0 10.0 0.0 20.0 1.0
0.0 -500000.0 500000.0 0.0 0.0 500000.0
Sample Output
3.14
4.44
6.28
31.42
62.83
632.24
3141592.65
*/
#include<iostream>//输入分别为三个点的坐标(x1,y1),(x2,y2),(x3,y3)
#include<cstdio>//利用海伦公式
#include<cstdlib>
#include<cmath>
#define PI 3.141592653589793
using namespace std;
int main()
{
double x1,x2,x3,y1,y2,y3;
double a,b,c,s,p,r,rt;
while(cin>>x1>>y1>>x2>>y2>>x3>>y3)//如果输入格式没有要求说明什么停止的,就这样输入
{
a=sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
b=sqrt((x3-x2)*(x3-x2)+(y3-y2)*(y3-y2));
c=sqrt((x3-x1)*(x3-x1)+(y3-y1)*(y3-y1));
p=(a+b+c)/2;
s=sqrt(p*(p-a)*(p-b)*(p-c));//三角形面积,海伦公式
r=a*b*c/(4*s);
rt=2*PI*r;
printf("%.2lf\n",rt);
}
return 0;
}
POJ 2242 The Circumference of the Circle的更多相关文章
- poj 1090:The Circumference of the Circle(计算几何,求三角形外心)
The Circumference of the Circle Time Limit: 2 Seconds Memory Limit: 65536 KB To calculate the c ...
- F - The Circumference of the Circle
Description To calculate the circumference of a circle seems to be an easy task - provided you know ...
- poj 2242(已知三点求外接圆周长)
The Circumference of the Circle Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 8310 ...
- ZOJ Problem Set - 1090——The Circumference of the Circle
ZOJ Problem Set - 1090 The Circumference of the Circle Time Limit: 2 Seconds Memory Limit: 65 ...
- POJ 2986 A Triangle and a Circle(三角形和圆形求交)
Description Given one triangle and one circle in the plane. Your task is to calculate the common are ...
- ZOJ 1090 The Circumference of the Circle
原题链接 题目大意:已知三角形的三个顶点坐标,求其外接圆的周长. 解法:刚看到这道题时,马上拿出草稿纸画图,想推导出重心坐标,然后求出半径,再求周长.可是这个过程太复杂了,写到一半就没有兴致了,还是求 ...
- POJ 2986 A Triangle and a Circle 圆与三角形的公共面积
计算几何模板 #include<stdio.h> #include<string.h> #include<stdlib.h> #include<math.h& ...
- POJ2242 The Circumference of the Circle(几何)
题目链接. 题目大意: 给定三个点,即一个任意三角形,求外接圆的周长. 分析: 外接圆的半径可以通过公式求得(2*r = a/sinA = b/sinB = c/sinC),然后直接求周长. 注意: ...
- 【POJ2242】The Circumference of the Circle(初等几何)
已知三点坐标,算圆面积. 使用初等几何知识,根据海伦公式s = sqrt(p(p - a)(p - b)(p - c)) 和 外接圆直径 d = a * b * c / (2s) 来直接计算. #in ...
随机推荐
- nginx configuration
Now that you know how to manage the service itself, you should take a few minutes to familiarize you ...
- Spring/Spring MVC/Spring Boot的区别
1.spring boot更简单,容易上手: 2.spring boot对第三方技术进行了很好的封装,提供了大量的第三方接口: 3.通过依赖配置,不需要XML等配置文件: 4.提供了安全性等特性. S ...
- 精通移动app测试实战
- API接口自动化之1 常见的http请求
常见的HTTP请求 就我所想到的,目前如果想做http/https请求接口自动户化,要处理的一些区别 get请求post请求 httphttps 单个值键值对键值对的搭配方式 POST请求体,后续讲一 ...
- JConsole监控远程Tomcat服务器 遇到的坑
1. 报错 JConsole java net socketException: Connection reset 解决: 先查看linux服务器开放了哪些端口 netstat -ntpl 选中了一 ...
- Windows 上安装 MySQL
Windows 上安装 MySQL https://www.mysql.com/downloads/ 1.下载MySQL安装包(官网下载链接): 选择 DOWNLOADS ——> Communi ...
- highcharts PHP中使用
官网 https://www.hcharts.cn/demo/highcharts html <div id="container" style="min-widt ...
- 使用 data.table 包操作数据
在第一节中,我们回顾了许多用于操作数据框的内置函数.然后,了解了 sqldf 扩展包,它使得简单的数据查询和统计变得更简便.然而,两种方法都有各自的局限性.使用内置函数可能既繁琐又缓慢,而相对于各式各 ...
- Qt5.3.2_CentOS6.4(x86)_代码文件编码
1.1.1.Qt5.3.2_MinGW 在Windows中安装时,默认的文件编码是 UTF8. 1.2.在 CentOS6.4中安装 qt-opensource-linux-x86-5.3.2.run ...
- 难部署的taiga,式微的circus——趋势从进程管理到容器管理,简单才是美
一直需要一个项目管理系统,一直没时间弄. taiga是github上搜project management star最多的项目,又是基于django用python写的后端,所以就用它: 但是,集中精力 ...