题目链接: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(解三角形重心)的更多相关文章

  1. POJ 1673 EXOCENTER OF A TRIANGLE(垂心)

    题目链接 折腾了半天,没想出怎么证明,以前初中老师教过,不知道怎么办,就量量...受不了,怒抄模版1Y... #include <cstdio> #include <iostream ...

  2. poj1673 EXOCENTER OF A TRIANGLE

    地址:http://poj.org/problem?id=1673 题目: EXOCENTER OF A TRIANGLE Time Limit: 1000MS   Memory Limit: 100 ...

  3. poj 1064 Cable master 判断一个解是否可行 浮点数二分

    poj 1064 Cable master 判断一个解是否可行 浮点数二分 题目链接: http://poj.org/problem?id=1064 思路: 二分答案,floor函数防止四舍五入 代码 ...

  4. hdu 2105:The Center of Gravity(计算几何,求三角形重心)

    The Center of Gravity Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Ot ...

  5. LeetCode Pascal's Triangle Pascal三角形

    题意:给一个数字,返回一个二维数组,包含一个三角形. 思路:n=0.1.2都是特例,特别处理.3行以上的的头尾都是1,其他都是依靠上一行的两个数.具体了解Pascal三角形原理. class Solu ...

  6. POJ 2947-Widget Factory(高斯消元解同余方程式)

    题目地址:id=2947">POJ 2947 题意:N种物品.M条记录,接写来M行,每行有K.Start,End,表述从星期Start到星期End,做了K件物品.接下来的K个数为物品的 ...

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

  8. poj 2352 Stars 数星星 详解

    题目: poj 2352 Stars 数星星 题意:已知n个星星的坐标.每个星星都有一个等级,数值等于坐标系内纵坐标和横坐标皆不大于它的星星的个数.星星的坐标按照纵坐标从小到大的顺序给出,纵坐标相同时 ...

  9. POJ - 3264 Balanced Lineup 线段树解RMQ

    这个题目是一个典型的RMQ问题,给定一个整数序列,1~N,然后进行Q次询问,每次给定两个整数A,B,(1<=A<=B<=N),求给定的范围内,最大和最小值之差. 解法一:这个是最初的 ...

随机推荐

  1. 自己写一个 wsgi 服务器运行 Django 、Tornado 等框架应用

    https://blog.csdn.net/heybob/article/details/52288006

  2. Normal Equation Algorithm

    和梯度下降法一样,Normal Equation(正规方程法)算法也是一种线性回归算法(Linear Regression Algorithm).与梯度下降法通过一步步计算来逐步靠近最佳θ值不同,No ...

  3. 爬虫(三)—— BeautifulSoup模块获取元素

    目录 BeautifulSoup 一.BeautifulSoup简介 二.安装模块 三.解析器 四.Beautiful Soup的使用 五.查找元素 1.遍历文档树 2.搜索文档树 Beautiful ...

  4. Java学习第一次总结

    在此之前我需要声明一下,我不载过多的评论知识点的简单与难易程度.写出来只是为了方便使用,现阶段追求的是实在.㈠①自动类型转换由低到高byte.short.char→int→long→flot→doub ...

  5. 一,Jetty启动

    一,Jetty安装 从官网download.eclipse.org/jetty/ 下载需要的版本,在指定目录解压即可,下面用$JETTY_HOME表示Jetty的解压目录,也就是安装目录.我用的版本是 ...

  6. Spring Boot集成Mybatis双数据源

    这里用到了Spring Boot + Mybatis + DynamicDataSource配置动态双数据源,可以动态切换数据源实现数据库的读写分离. 添加依赖 加入Mybatis启动器,这里添加了D ...

  7. CVE-2010-4258漏洞分析

    Nelson Elhage最近发现了一个内核设计上的漏洞, 通过利用这个漏洞可以将一些以前只能dos的漏洞变成可以权限提升的漏洞. 当fork一个进程在的时候, copy_process执行如下操作: ...

  8. Window/Linux + Vim + MingW 配置

    Windows: 首先安装Vim , MinGW,假设安装目录为D:\MinGW. 配置环境变量: LIBRARY_PATH=D:\MinGW\lib C_INCLUDE_PATH=D:\MinGW\ ...

  9. servlet配置url-pattern的匹配规则

    <servlet> <servlet-name>hello</servlet-name> <servlet-class>com.qf.servlet.H ...

  10. windows xp .net framework 4.0 HttpWebRequest 报The underlying connection was closed,基础连接已关闭

    windows xp .net framework 4.0 HttpWebRequest 报The underlying connection was closed,基础连接已关闭,错误的解决方法 在 ...