已知三点坐标,算圆面积。

使用初等几何知识,根据海伦公式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(初等几何)的更多相关文章

  1. POJ2242 The Circumference of the Circle(几何)

    题目链接. 题目大意: 给定三个点,即一个任意三角形,求外接圆的周长. 分析: 外接圆的半径可以通过公式求得(2*r = a/sinA = b/sinB = c/sinC),然后直接求周长. 注意: ...

  2. F - The Circumference of the Circle

    Description To calculate the circumference of a circle seems to be an easy task - provided you know ...

  3. poj 1090:The Circumference of the Circle(计算几何,求三角形外心)

    The Circumference of the Circle Time Limit: 2 Seconds      Memory Limit: 65536 KB To calculate the c ...

  4. 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 ...

  5. ZOJ 1090 The Circumference of the Circle

    原题链接 题目大意:已知三角形的三个顶点坐标,求其外接圆的周长. 解法:刚看到这道题时,马上拿出草稿纸画图,想推导出重心坐标,然后求出半径,再求周长.可是这个过程太复杂了,写到一半就没有兴致了,还是求 ...

  6. 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);//这是外接 ...

  7. poj2242

                                                        The Circumference of the Circle Time Limit: 1000 ...

  8. [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 ...

  9. [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 ...

随机推荐

  1. Tomcat 改变localhost主页,映射到应用地址

    <Host appBase="webapps" autoDeploy="true" name="localhost" unpackWA ...

  2. c# 可变性解析(协变和逆变)

    之所以会想写关于协变和逆变的知识点,主要是因为在泛型委托中提到了这个知识点. 1.什么是可变性 可变性是.NET4.0中的一个特性,可变形分为:协变性,逆变性,不可变性. 2.在.NET4.0出来之前 ...

  3. asdasd

    adasdasd asdasd asdasd asd

  4. Java_io体系之PipedWriter、PipedReader简介、走进源码及示例——14

    Java_io体系之PipedWriter.PipedReader简介.走进源码及示例——14 ——管道字符输出流.必须建立在管道输入流之上.所以先介绍管道字符输出流.可以先看示例或者总结.总结写的有 ...

  5. openfire连接登陆优化方案

    client登陆openfire,大概总共须要9个来回才完毕登录. 在2G情况下.就表现为client登录特别慢,所以,为解决问题,对openfire进行了例如以下优化 openfire的连接.登陆过 ...

  6. 只响应ccTouchBegan的问题

    在Touch事件中,ccTouchBegan有一个返回值,而这一个返回值则决定了是否会继续响应ccTouchMoved,ccTouchEnded. 如果没有返回true的话,则直接会结束此Touch事 ...

  7. 关于material和sharedMaterial的问题

    在unity3d中,Renderer组件有两个属性:material和sharedMaterial,它们都可以用来获取Renderer的材质属性.但是它们之间却又很大的区别,下面通过示例来讲解一下. ...

  8. Java多线程练习二

    public class ex3 { public static void main(String [] args) { thread2 t1 = new thread2("hello&qu ...

  9. javascript正则

      <script type="text/javascript"> //去除两边空格,如果要去除所有空格,使用/\s*即可/ String.prototype.trim ...

  10. Sql Server添加用户

    1.sa用户登陆之后,在安全性中新建登录名 2.添加登录名,下面的默认数据库选择该用户可访问的默认数据库 3.服务器角色中选择public 4.用户映射中选择该用户可访问的数据库,数据库角色一般选择p ...