13山东ACM省赛(第四届)problem A rescue the princess
题目链接:http://sdjzu.acmclub.com/index.php?app=problem_title&id=147&problem_id=2558
几何水
题目大意:营救公主,equilateral triangle意思是等边三角形,anticlockwise是逆时针方向。
题目分析:画个图就出(有相似三角形)
code:
#include<stdio.h>
#include<math.h>
int main()
{
int t,flagx,flagy;
double x1,x2,y1,y2,xq,yq;
scanf("%d",&t);
while(t--)
{
scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);
flagy=x2>x1?1:-1;
flagx=y2>y1?-1:1;
xq=(x1+x2)/2;
yq=(y1+y2)/2;
xq+=flagx*sqrt(3)*fabs(y2-y1)/2;
yq+=flagy*sqrt(3)*fabs(x2-x1)/2;
printf("(%.2f,%.2f)\n",xq,yq);
}
}
PS:比赛就出这一道……TAT