POJ2242 The Circumference of the Circle(几何)
题目链接。
题目大意:
给定三个点,即一个任意三角形,求外接圆的周长。
分析:
外接圆的半径可以通过公式求得(2*r = a/sinA = b/sinB = c/sinC),然后直接求周长。
注意:
C++AC,G++WA。
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath> using namespace std; const double PI = 3.141592653589793; typedef struct Point {
double x, y;
Point (double x=, double y=):x(x),y(y) {};
}Vector; double Dot(Vector A, Vector B) { return A.x*B.x + A.y*B.y; }
double Length(Vector A) { return sqrt(Dot(A, A)); }
double Cross(Vector A, Vector B) { return A.x*B.y - A.y*B.x; } int main(){
double x1, y1, x2, y2, x3, y3, d; while(cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3) {
Vector A(x2-x1, y2-y1), B(x3-x1, y3-y1), C(x3-x2, y3-y2); d = Length(C) / (fabs(Cross(A, B)) / Length(A) / Length(B)); printf("%.2lf\n", d*PI);
} return ;
}
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 ...
- 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 ...
- 【POJ2242】The Circumference of the Circle(初等几何)
已知三点坐标,算圆面积. 使用初等几何知识,根据海伦公式s = sqrt(p(p - a)(p - b)(p - c)) 和 外接圆直径 d = a * b * c / (2s) 来直接计算. #in ...
- 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);//这是外接 ...
- UVA 11355 Cool Points(几何)
Cool Points We have a circle of radius R and several line segments situated within the circumference ...
- 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 ...
随机推荐
- 黑马程序猿_try-catch-finally
------- android培训.java培训.期待与您交流! ---------- try-catch-finally中怎样定义语句呢? 1.try块中主要定义可能出现的异常处理语句 2.catc ...
- [PWA] 11. Serve skeleton cache for root
Intead of cache the root floder, we want to cache skeleton instead. self.addEventListener('install', ...
- cocos2d-x项目过程记录(跨平台iOS和Android)
(原创作品,欢迎转载,注明出处,谢谢:http://www.cnblogs.com/binxindoudou/admin/EditPosts.aspx?postid=3205249) 1.配置环境,重 ...
- html contenteditable
contenteditable 是html中的一個屬性,在HTML中,某些元素設置 contenteditable='true' 屬性時可以開啟該元素的編輯模式,contenteditable 可以 ...
- Android(java)学习笔记237:多媒体之图形的变化处理
1.图形的缩放 (1)布局文件activity_main.xml如下: <LinearLayout xmlns:android="http://schemas.android.com/ ...
- U口破解指令介绍.
- MySQL存储过程(一)
1.1 CREATE PROCEDURE (创建) CREATE PROCEDURE存储过程名 (参数列表) BEGIN SQL语句代码块 END 注意: 由括号包围的参数列必须总是存在.如果没有参 ...
- My.Ioc 代码示例——使用条件绑定和元数据(可选)构建插件树
本文旨在通过创建一棵插件树来演示条件绑定和元数据的用法. 说“插件树”也许不大妥当,因为在一般观念中,谈到插件树,我们很容易会想到 Winform/Wpf 中的菜单.举例来说,如果要在 Winform ...
- java中的IO二
java中流分为节点流和处理流,IO一中的案例都是节点流 一.处理流的使用实例 二.装饰者模式 以上BufferReader的用法就是装饰者模式 Decorator就是动态地给对象增添行为 如果要实现 ...
- 分页技术之GridView控件
GridView控件实现分页技术 第一步:设置GridView控件的属性,跟分页相关的属性设置如下: AllowPaging="true":允许分页, PageSize=" ...