题目的链接如下:
https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2119
题目的VJ链接如下:
http://acm.hust.edu.cn/vjudge/problem/18543
题目格式是PDF的而且有图形,就不在这里说了,把题目的大意说一下,就是他给你一个定理叫做 Morley定理,任意三角形的三个角的6条三等分线会交出一个等边三角形记作△DEF,那么现在给出△ABC的三个顶点,请计算D、E、F的坐标.
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
struct point{
// public:
double x, y;
point(double x = 0 , double y = 0):x(x), y(y){};
};
typedef point Vector;
Vector operator + (Vector A, Vector B){return Vector(A.x+B.x, A.y+B.y);}
Vector operator - (Vector A, Vector B){return Vector(A.x-B.x, A.y-B.y);}
Vector operator * (Vector A, double p){return Vector(A.x*p, A.y*p);}
Vector operator / (Vector A, double p){return Vector(A.x/p, A.y/p);}
double cross(Vector A, Vector B){//叉积
return A.x * B.y - A.y * B.x;
}
point get_line(point P, Vector v, point Q, Vector w)//直线的表达方式,参数法
{
Vector u = P-Q;
double t = cross(w,u)/cross(v,w);
return P+v*t;
}
Vector Rotate(Vector A, double rad)//向量旋转(逆时针为正角)
{
return Vector (A.x*cos(rad) - A.y*sin(rad), A.x*sin(rad) + A.y*cos(rad));
}
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 angle(Vector A, Vector B){return acos(dot(A,B)/length(A)/length(B));}//两个向量之间的夹角
point get_ans(point A, point B, point C){
Vector v1 = C - B;
double a1 = angle(A-B, v1);
v1 = Rotate(v1, a1/3);
Vector v2 = B - C ;
double a2 = angle(A-C, v2);
v2 = Rotate(v2, -a2/3);
return get_line(B, v1, C, v2);
}
int main()
{
point D, E, F;
point A, B, C;
int n,t ;
cin >> t;
while(t--){
//cin >> A.x >> A.y >> B.x >> B.y >> C.x >> C.y;
scanf("%lf%lf%lf%lf%lf%lf",&A.x,&A.y,&B.x,&B.y,&C.x,&C.y);
D = get_ans(A,B,C);
E = get_ans(B,C,A);
F = get_ans(C,A,B);
printf("%.6f %.6f %.6f %.6f %.6f %.6f\n", D.x, D.y, E.x, E.y, F.x, F.y);
}
return 0;
}
/*测试数据
2
1 1 2 2 1 2
*/