POJ 1673 EXOCENTER OF A TRIANGLE(解三角形重心)
题目链接:http://poj.org/problem?id=1673
AC代码:
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
typedef long long ll;
const double eps = 1e-;
const double pi = acos(-1.0);
int sgn(double x)
{
if(fabs(x) < eps) return ;
else return x < ? - : ;
}
struct Point{
double x, y;
Point(){}
Point(double _x, double _y){
x = _x, y = _y;
}
bool operator == (Point b) const{
return sgn(x - b.x) == && sgn(y - b.y) == ;
}
bool operator < (Point b)const{
return sgn(x - b.x) == ? sgn(y - b.y < ) : x < b.x;
}
Point operator - (const Point &b)const{
return Point(x - b.x, y - b.y);
}
//²æ»ý
double operator ^(const Point &b){
return x * b.y - y * b.x;
}
//µã»ý
double operator *(const Point &b){
return x * b.x + y * b.y;
}
double len(){
return hypot(x, y);
}
double len2(){
return x * x + y * y;
}
double distant(Point p){
return hypot(x - p.x, y - p.y);
}
Point operator + (const Point &b)const{
return Point (x + b.x, y + b.y);
}
Point operator * (const double &k)const{
return Point(x * k, y * k);
}
Point operator / (const double &k)const{
return Point(x / k, y / k);
}
Point rotate(Point p, double angle){
Point v = (*this) - p;
double c = cos(angle), s = sin(angle);
return Point(p.x + v.x * c - v.y * s, p.y + v.x * s + v.y * c);
}
};
Point GetLineIntersection(Point P, Point v, Point Q, Point w){
Point u = P - Q;
double t =(w^u)/(v^w);
return P + v*t;
}
int main()
{
Point A, B, C;
int n;
scanf("%d",&n);
while(n--)
{
scanf("%lf %lf %lf %lf %lf %lf",&A.x, &A.y, &B.x, &B.y, &C.x, &C.y);
Point v = B,u = C;
v = v.rotate(A, pi / 2.0), u = u.rotate(B, pi / 2.0);
Point c = GetLineIntersection(C, v - A, A, u - B);
printf("%.4f %.4f\n",c.x + eps, c.y + eps);
}
return ;
}
POJ 1673 EXOCENTER OF A TRIANGLE(解三角形重心)的更多相关文章
- POJ 1673 EXOCENTER OF A TRIANGLE(垂心)
题目链接 折腾了半天,没想出怎么证明,以前初中老师教过,不知道怎么办,就量量...受不了,怒抄模版1Y... #include <cstdio> #include <iostream ...
- poj1673 EXOCENTER OF A TRIANGLE
地址:http://poj.org/problem?id=1673 题目: EXOCENTER OF A TRIANGLE Time Limit: 1000MS Memory Limit: 100 ...
- poj 1064 Cable master 判断一个解是否可行 浮点数二分
poj 1064 Cable master 判断一个解是否可行 浮点数二分 题目链接: http://poj.org/problem?id=1064 思路: 二分答案,floor函数防止四舍五入 代码 ...
- hdu 2105:The Center of Gravity(计算几何,求三角形重心)
The Center of Gravity Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Ot ...
- LeetCode Pascal's Triangle Pascal三角形
题意:给一个数字,返回一个二维数组,包含一个三角形. 思路:n=0.1.2都是特例,特别处理.3行以上的的头尾都是1,其他都是依靠上一行的两个数.具体了解Pascal三角形原理. class Solu ...
- POJ 2947-Widget Factory(高斯消元解同余方程式)
题目地址:id=2947">POJ 2947 题意:N种物品.M条记录,接写来M行,每行有K.Start,End,表述从星期Start到星期End,做了K件物品.接下来的K个数为物品的 ...
- hdu 1451 Area in Triangle(计算几何 三角形)
Given a triangle field and a rope of a certain length (Figure-1), you are required to use the rope t ...
- poj 2352 Stars 数星星 详解
题目: poj 2352 Stars 数星星 题意:已知n个星星的坐标.每个星星都有一个等级,数值等于坐标系内纵坐标和横坐标皆不大于它的星星的个数.星星的坐标按照纵坐标从小到大的顺序给出,纵坐标相同时 ...
- POJ - 3264 Balanced Lineup 线段树解RMQ
这个题目是一个典型的RMQ问题,给定一个整数序列,1~N,然后进行Q次询问,每次给定两个整数A,B,(1<=A<=B<=N),求给定的范围内,最大和最小值之差. 解法一:这个是最初的 ...
随机推荐
- 查看静态库(.lib)和动态库(.dll)的导出函数的信息 error LNK2001: 无法解析的外部符号 _Delete
转自VC错误:http://www.vcerror.com/?p=1381 在window下查看动态库的导出函数可以用vs自带的Dependenc工具: 查看静态库的信息要用命令行来实现: 首先运行V ...
- Python selenium web UI之Chrome 与 Chromedriver对应版本映射表及下载地址和配置(windows, Mac OS)
浏览器及驱动下载 进行web UI 自动化时,需要安装浏览器驱动webdriver,Chrome浏览器需要安装chromedriver.exe 驱动,Firefox需安装 geckodriver.ex ...
- Java 空字符串和 字符串为null的区别
之前一直没有搞清楚 字符串为空和字符串为null的区别,今天写代码一直出现NullPointerException异常,我一直没有搞清楚,后来发现我是这样写的 String s = null; s = ...
- Spring快速开启计划任务
Spring3.1开始让计划任务变得非常简单,只需要几个注解就能快速开启计划任务的支持. @EnableScheduling @Target(ElementType.TYPE) @Retention( ...
- Windows Nginx 教程
1. 下载Nginx: Nginx下载 (官方网站) 作者使用版本 Stable version nginx/Windows-1.12.0
- C# FTP操作代码实现
C# FTP 实现方式,废话不多说,直接上代码 public class FtpClient { #region 构造函数 /// <summary> /// 创建FTP工具 /// & ...
- 自定义input[type="radio"]
对于表单,input[type="radio"] 的样式总是不那么友好,在不同的浏览器中表现不一. 对单选按钮自定义样式,我们以前一直用的脚本来实现,不过现在可以使用新的伪类 :c ...
- python获取网页源代码
最简单的网页取源(不用模拟浏览器的情况) import requests def getHTML(url): try: r = requests.get(url,timeout=30) r.raise ...
- 实现一个EventEmitter类,这个类包含以下方法: on/ once/fire/off
实现一个EventEmitter类,这个类包含以下方法: on(监听事件,该事件可以被触发多次)- once(也是监听事件,但只能被触发一次)- fire(触发指定的事件)- off(移除指定事件的某 ...
- Android 增量更新完全解析 是增量不是热修复(转)
转自:http://blog.csdn.net/lmj623565791/article/details/52761658 本文在我的微信公众号:鸿洋(hongyangAndroid)首发. 转载请标 ...