【POJ2242】The Circumference of the Circle(初等几何)

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

使用初等几何知识,根据海伦公式s = sqrt(p(p - a)(p - b)(p - c)) 和 外接圆直径 d = a * b * c / (2s) 来直接计算。

 1 #include <iostream>
 2 #include <cstring>
 3 #include <cstdlib>
 4 #include <cstdio>
 5 #include <numeric>
 6 #include <cctype>
 7 #include <cmath>
 8 #include <algorithm>
 9
10 #define PI acos(-1)
11 using namespace std;
12
13 double calc_dis (double x1, double y1, double x2, double y2) {
14     return sqrt ((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
15 }
16
17 int main () {
18     ios :: sync_with_stdio(false);
19     double x[3], y[3];
20     while (cin >> x[0] >> y[0]) {
21         for (int i = 1; i < 3; ++ i) {
22             cin >> x[i] >> y[i];
23         }
24         double a, b, c;
25         a = calc_dis (x[0], y[0], x[1], y[1]);
26         b = calc_dis (x[0], y[0], x[2], y[2]);
27         c = calc_dis (x[2], y[2], x[1], y[1]);
28         //cout << a << " " << b << " " << c << endl;
29         double p = (a + b + c) / 2;
30         double s = sqrt (p * (p - a) * (p - b) * (p - c));
31         //cout << "s : " << s << endl;
32         double d = a * b * c / (2 * s);
33         printf ("%.2f\n", PI * d);
34     }
35     return 0;
36 }
时间: 2024-10-14 12:38:00

【POJ2242】The Circumference of the Circle(初等几何)的相关文章

F - The Circumference of the Circle

Description To calculate the circumference of a circle seems to be an easy task - provided you know its diameter. But what if you don't?         You are given the cartesian coordinates of three non-collinear points in the plane.         Your job is t

poj 2242 The Circumference of the Circle

题目大意:给出三个点的坐标,求三点组成的三角形的外接圆的周长,假设已知三角形边长a,b,c和三角形面积s,则外接圆直径 d = (a*b*c)/(2*s) #include <iostream> #include <cmath> #include <iomanip> using namespace std; const double pi=3.141592653589793; int main() { double x1,y1,x2,y2,x3,y3,a,b,c,st,

poj2242

The Circumference of the Circle Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7032   Accepted: 4361 Description To calculate the circumference of a circle seems to be an easy task - provided you know its diameter. But what if you don't

[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 generates a uniform random point in the circle. Note: input and output values are in floating-point. radius and x-y position of the center of the circle is

H - Ones

Description Given any integer 0 <= n <= 10000 not divisible by 2 or 5, some multiple of n is a number which in decimal notation is a sequence of 1's. How many digits are in the smallest such a multiple of n? Input Each line contains a number n. Outp

杭电ACM分类

杭电ACM分类: 1001 整数求和 水题1002 C语言实验题——两个数比较 水题1003 1.2.3.4.5... 简单题1004 渊子赛马 排序+贪心的方法归并1005 Hero In Maze 广度搜索1006 Redraiment猜想 数论:容斥定理1007 童年生活二三事 递推题1008 University 简单hash1009 目标柏林 简单模拟题1010 Rails 模拟题(堆栈)1011 Box of Bricks 简单题1012 IMMEDIATE DECODABILITY

uva 01510

1510 - Neon Sign JungHeum recently opened a restaurant called ‘Triangle’ and has ordered the following neon sign for hisrestaurant. The neon sign has N corners positioned on the circumference of a circle, and N ∗ (N −1)/2luminous tubes that connect t

北大ACM题库习题分类与简介(转载)

在百度文库上找到的,不知是哪位大牛整理的,真的很不错! zz题 目分类 Posted by fishhead at 2007-01-13 12:44:58.0 -------------------------------------------------------------------------------- acm.pku.edu.cn 1. 排序 1423, 1694, 1723, 1727, 1763, 1788, 1828, 1838, 1840, 2201, 2376, 23

最著名的十大公式

最著名的十大公式 No.10 圆的周长公式(The Length of the Circumference of a Circle) No.9 傅立叶变换(The Fourier Transform) No.8 德布罗意方程组(The de Broglie Relations) No.7 1+1=2 No.6 薛定谔方程(The Schrödinger Equation) 薛定谔方程是世界原子物理学文献中应用最广泛.影响最大的公式. No.5 质能方程(Mass–energy Equivalen