NC207613. windmill
描述
输入描述
The first line contains one integer n that there are n points in total.
The first line contains three integers x, y and β to indicate the point P and the angle formed by the anticlockwise direction of line L and X-axis (angle representation) ( 1 < = n < = 1000, -1000 < = x, y < = 1000; 0 < = β < 360)
The next n-1 lines, each line contains two integers x, y, representing the coordinates of the point
The last line contains α to indicate the rotation angle of the line L. (0<=α<=360000)
输出描述
Print the only line containing two integers x and y to indicate the point .
示例1
输入:
3 1 0 30 0 0 1 1 45
输出:
0 0
C++11(clang++ 3.9) 解法, 执行用时: 813ms, 内存消耗: 628K, 提交时间: 2020-06-07 17:53:37
#include<bits/stdc++.h> using namespace std; struct point{ double x,y; void sc(){ scanf("%lf%lf",&x,&y); } double len(){ return sqrt(x*x+y*y); } double cross(point b){ return x*b.y-y*b.x; } double dot(point b){ return x*b.x+y*b.y; } point operator-(point b){ return {x-b.x,y-b.y}; } }p[2000]; double angle(point a,point b){ const double pi=acos(-1); double t=atan2(a.y,a.x)-atan2(b.y,b.x); t=fmod(t,2*pi); if(t<0)t+=2*pi; return t; } int main(){ int n; scanf("%d",&n); point o; o.sc(); double a; scanf("%lf",&a); const double pi=acos(-1); a=a*pi/180; p[0]=o; for(int i=1;i<n;i++){ p[i].sc(); } point v={cos(a),sin(a)}; int pos=0; scanf("%lf",&a); a=fmod(a,360); a=a*pi/180; int op=0,opp=0; while(a>0){ double cur=1e9; for(int i=0;i<n;i++){ if(i==op||i==opp)continue; double d=min(angle(v,o-p[i]),angle(v,p[i]-o)); if(d<cur){ pos=i; cur=d; } } if(a<cur){ cout<<o.x<<' '<<o.y<<endl; return 0; } a-=cur; opp=op; v=p[pos]-o; o=p[pos]; op=pos; } cout<<o.x<<' '<<o.y; }