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 ...
随机推荐
- Linux内核同步机制--自旋锁【转】
本文转载自:http://www.cppblog.com/aaxron/archive/2013/04/12/199386.html 自旋锁与互斥锁有点类似,只是自旋锁不会引起调用者睡眠,如果自旋锁已 ...
- linux指定某用户某组挂载外接硬盘以便操作硬盘
一.环境:发行版本:ubuntu 14.04 64bit 二.获取要指定的用户及组id 使用id命令 (笔者获取的uid和gid都为1000) 三.获取识别的硬盘路径 sudo fdisk -l ( ...
- 分页器的js实现代码 bootstrap Paginator.js
参考: http://www.jb51.net/article/76093.htm 如前所述, 不要什么都想到 jquery的 脚本js, 应该首先推荐的是 css 和 元素本身的事件 函数 如: o ...
- luogu P2114 [NOI2014]起床困难综合症 位运算 二进制
建议去uoj那里去测,数据比较强 位运算的题目,就得一位一位的分开考虑 然后枚举初始值的最高位是0 是1 的最终攻击 (二进制内)最高位是1肯定比次位是1次次位是1次次次位是1···的大吧,显然 然后 ...
- P2472 [SCOI2007]蜥蜴(网络最大流)
P2472 [SCOI2007]蜥蜴 题目描述 在一个r行c列的网格地图中有一些高度不同的石柱,一些石柱上站着一些蜥蜴,你的任务是让尽量多的蜥蜴逃到边界外. 每行每列中相邻石柱的距离为1,蜥蜴的跳跃距 ...
- 海量数据处理-BitMap算法
一.概述 本文将讲述Bit-Map算法的相关原理,Bit-Map算法的一些利用场景,例如BitMap解决海量数据寻找重复.判断个别元素是否在海量数据当中等问题.最后说说BitMap的特点已经在各个场景 ...
- HDU3085(双向BFS+曼哈顿距离)题解
Nightmare Ⅱ Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Tota ...
- UVa 1630 串折叠
https://vjudge.net/problem/UVA-1630 题意: 给出一个由大写字母组成的长度为n的串,折叠成一个尽量短的串.例如:AAAAAAAAABABABCCD折叠成9(A)3(A ...
- c++ 查找数组或者容器元素是否存在(find)
#include <iostream> // cout #include <algorithm> // find #include <vector> // vect ...
- spring boot 开发 org.springframework.context.ApplicationContextException: Unable to start web server;
Error starting ApplicationContext. To display the conditions report re-run your application with 'de ...