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 ...
随机推荐
- Firemonkey的旁门左道[五]
这次讲讲绘制的几种模式吧,不过还是比较浅显,刚接触不久,还实在没这个实力道出个所以来. FMX下,我们可以切换GDI,D2D,GPU这三种模式, 只要通过全局变量就可以轻松搞定. 如何设置 Globa ...
- Java Math 类中的新功能--浮点数
Java™语言规范第 5 版向 java.lang.Math和 java.lang.StrictMath添加了 10 种新方法,Java 6 又添加了 10 种.这个共两部分的系列文章的 第 1 部分 ...
- 使用日期工具类:DateUtil
利用java开发,避免不了String.Date转换,前一天.后一天等问题.给出一个工具类,仅供学习交流. import java.text.DateFormat; import java.text. ...
- Android系统移植与驱动开发----第一章
第一章 Android系统移植与驱动开发 Android源代码定制完全属于自己的嵌入式系统,但是支持的设备不多,所以要移植,而在移植的过程中使用的不得不提的是驱动开发. Android系统构架主要包括 ...
- CDOJ 92 – Journey 【LCA】
[题意]给出一棵树,有n个点(2≤N≤105),每条边有权值,现在打算新修一条路径,给出新路径u的起点v,终点和权值,下面给出Q(1≤Q≤105)个询问(a,b)问如果都按照最短路径走,从a到b节省了 ...
- Jquery小东西收集
1. $(document).ready(),$(function(){}),$(window).load(),window.onload的关系与区别 $(document).ready(functi ...
- 在CSS文件中引入其他CSS文件
引入CSS的方法有两种,一种是@import,一种是link 一.@import url('地址');二.<link href="地址" rel="styleshe ...
- android开发中的5种存储数据方式
数据存储在开发中是使用最频繁的,根据不同的情况选择不同的存储数据方式对于提高开发效率很有帮助.下面笔者在主要介绍Android平台中实现数据存储的5种方式. 1.使用SharedPreferences ...
- class-loader.
the jdk hierarchical relationship of class-loader ----Module Class Loading and Bootstrapping---- boo ...
- Swift - 17 - 数组的初始化
import UIKit // 声明数组 var array = ["A", "B", "C", "D", " ...