【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 ...
随机推荐
- Python偏函数实例
目标: 1.编写一个gui,生成按钮 2.通过偏函数,生成按钮 3.通过装饰器,实现按钮输出信息功能 1.使用Tkinter,创建一个按钮 代码如下: handetiandeMacBook-Pro:~ ...
- Apache https 配置指南
Windows Apache HTTPS配置创建下面3个目录: C:\Program Files\Apache Group\Apache2\conf\sslC:\Program Files\Apach ...
- struts2操作数据库
struts2操作数据库是刚開始学习的人的一个难点也是一个重点,如今我为大家解说一下struts2操作数据库,使用struts2对数据库进行增.删.改.查和分页查询,请看以下的代码: User类 pu ...
- MVC 5.0 之奇葩错误-<类型“ASP._Page__ViewStart_cshtml”不从“System.Web.WebPages.StartPage”继承>
在实际项目中,我们通常添加MVC项目会先添加一个MVC Empty 的项目,然后需要什么在往里面添加. 但是Empty项目里面只有一个路由注册,而且没有_ViewStart.cshtml文件需要自己添 ...
- (转)jQuery验证控件jquery.validate.js使用说明+中文API
官网地址:http://bassistance.de/jquery-plugins/jquery-plugin-validation jQuery plugin: Validation 使用说明 转载 ...
- 随机获取oracle数据库中的任意一行数据(rownum)
最近看oracle资料的时候,了解rownum的概念,以前只知道对数据库表进行简单的增删改查: 看到了rownum的概念后,突然想到了好多业务场景应该都可以适用的,比如在进行随机发奖的时候, 我们就可 ...
- C#多线程实践——线程同步
下面的表格列展了.NET对协调或同步线程动作的可用的工具: 简易阻止方法 构成 目的 Sleep 阻止给定的时间周期 Join 等待另一个线程完成 ...
- jQuery操作元素
通常,我们在创建元素时,会使用以下代码: var p = document.createElement("p"); p.innerText = "this is para ...
- PL/SQL Developer主界面窗口左边窗口默认设置
中文版:在菜单 工具 -> 首选项 -> 用户界面 -> 选项 窗口中,将“自动保存桌面”勾选上就可以了. 截图如下: 英文版:在菜单 Tools -> Preferences ...
- 《APUE》读书笔记第十二章-线程控制
本章中,主要是介绍控制线程行为方面的内容,同时介绍了在同一进程中的多个线程之间如何保持数据的私有性以及基于进程的系统调用如何与线程进行交互. 一.线程属性 我们在创建线程的时候可以通过修改pthrea ...