【POJ2242】The Circumference of the Circle(初等几何)
已知三点坐标,算圆面积。
使用初等几何知识,根据海伦公式s = sqrt(p(p - a)(p - b)(p - c)) 和 外接圆直径 d = a * b * c / (2s) 来直接计算。
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <numeric>
#include <cctype>
#include <cmath>
#include <algorithm> #define PI acos(-1)
using namespace std; double calc_dis (double x1, double y1, double x2, double y2) {
return sqrt ((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
} int main () {
ios :: sync_with_stdio(false);
double x[], y[];
while (cin >> x[] >> y[]) {
for (int i = ; i < ; ++ i) {
cin >> x[i] >> y[i];
}
double a, b, c;
a = calc_dis (x[], y[], x[], y[]);
b = calc_dis (x[], y[], x[], y[]);
c = calc_dis (x[], y[], x[], y[]);
//cout << a << " " << b << " " << c << endl;
double p = (a + b + c) / ;
double s = sqrt (p * (p - a) * (p - b) * (p - c));
//cout << "s : " << s << endl;
double d = a * b * c / ( * s);
printf ("%.2f\n", PI * d);
}
return ;
}
【POJ2242】The Circumference of the Circle(初等几何)的更多相关文章
- POJ2242 The Circumference of the Circle(几何)
题目链接. 题目大意: 给定三个点,即一个任意三角形,求外接圆的周长. 分析: 外接圆的半径可以通过公式求得(2*r = a/sinA = b/sinB = c/sinC),然后直接求周长. 注意: ...
- F - The Circumference of the Circle
Description To calculate the circumference of a circle seems to be an easy task - provided you know ...
- poj 1090:The Circumference of the Circle(计算几何,求三角形外心)
The Circumference of the Circle Time Limit: 2 Seconds Memory Limit: 65536 KB To calculate the c ...
- 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 ...
- ZOJ 1090 The Circumference of the Circle
原题链接 题目大意:已知三角形的三个顶点坐标,求其外接圆的周长. 解法:刚看到这道题时,马上拿出草稿纸画图,想推导出重心坐标,然后求出半径,再求周长.可是这个过程太复杂了,写到一半就没有兴致了,还是求 ...
- 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);//这是外接 ...
- poj2242
The Circumference of the Circle Time Limit: 1000 ...
- [Swift]LeetCode478. 在圆内随机生成点 | Generate Random Point in a Circle
Given the radius and x-y positions of the center of a circle, write a function randPoint which gener ...
- [LeetCode] Generate Random Point in a Circle 生成圆中的随机点
Given the radius and x-y positions of the center of a circle, write a function randPoint which gener ...
随机推荐
- JS-string内置对象
1.charCodeAt方法返回一个整数,代表指定位置字符的Unicode编码. strObj.charCodeAt(index) 说明: index将被处理字符的从零开始计数的编号.有效值为0到字符 ...
- [C++]memcpy 小记
#include <stdio.h> #include <stdlib.h> #include <string.h> int main () { char a = ...
- chrome devtools 实用快捷键
Ctrl + O:查找资源,非常使用 Ctrl + Shift + C:切换审查元素模式与浏览器窗口模式 Ctrl + Shift + F:在源代码中搜索 Ctrl + G:跳转到指定行
- (转)在SAE使用Apple Push Notification Service服务开发iOS应用, 实现消息推送
在SAE使用Apple Push Notification Service服务开发iOS应用, 实现消息推送 From: http://saeapns.sinaapp.com/doc.html 1,在 ...
- Android中的windowSoftInputMode属性详解
这篇文章主要介绍了Android中的windowSoftInputMode属性详解,本文对windowSoftInputMode的9个属性做了详细总结,需要的朋友可以参考下 在前面的一篇文章中 ...
- 整型数组处理算法(八)插入(+、-、空格)完成的等式:1 2 3 4 5 6 7 8 9=N[华为面试题]
有一个未完成的等式:1 2 3 4 5 6 7 8 9=N 当给出整数N的具体值后,请你在2,3,4,5,6,7,8,9这8个数字的每一个前面,或插入运算符号“+”,或插入一个运算符号“-”,或不插入 ...
- 【转】Linux中安装Resin
安装步骤: Ø 安装resin前先要保证安装了JDK,可以用命令查看是否安装了JDK: [root@wxr webapps]# java -versions java version " ...
- DOM模型结构——节点类型
- Python 日期和时间(转)
Python 日期和时间 Python程序能用很多方式处理日期和时间.转换日期格式是一个常见的例行琐事.Python有一个 time 和 calendar 模组可以帮忙. 什么是Tick? 时间间隔是 ...
- Linux能力(capability)机制的继承
1.Linux能力机制概述 在以往的UNIX系统上,为了做进程的权限检查,把进程分为两类:特权进程(有效用户ID是0)和非特权进程(有效用户ID是非0).特权进程可以通过内核所有的权限检查,而非特权进 ...