2013
12-12

Searching

"You know what?" Angel said, "There is a love-letter from me embeded on the lawn. And if you can find it, it’s for you~"
"How can I find it on such a big lawn?"
"I will show you a hint: start from that tree which is in center of this lawn, and run directly to (X,Y) point. Please memorize the distance you’v passed. Then turn left with a angle A degree, and go ahead for k times of the length you’v passed in the first step. k is a real number from 0 to 1. When you arrive, repeat to turn left, and run for k times as far as the length of the last step. After many many times, you will reach a place, where I embed my letter…"
Of cause, Gardon wouldn’t follow her hint simply. He just run there directly. Can you do it?

Input have serveral test cases. Each cases have for real number: X,Y,A,k

For each case, print the place where the treasure is embed.

1 0 90 0.5
1 0 90 0
1 0 0 0.5

(0.800,0.400)
(1.000,0.000)
(2.000,0.000)

x’=x*cos(a)-y*sin(a);
y’=y*cos(a)+x*sin(a);
=>(x’+y’i)=k*(cos(a)+sin(a)i)*(x+yi);

#include<cstring>
#include<complex>
#include<cmath>
#define pi acos(-1.0)
using namespace std;
typedef complex<double>Comp;
double x,y,A,k;
int main()
{
int i,j;
while(scanf("%lf%lf%lf%lf",&x,&y,&A,&k)!=EOF)
{
A=A*pi/180.0;
Comp a(x,y);
Comp b(1-k*cos(A),-k*sin(A));
Comp c=a/b;

printf("(%.3lf,%.3lf)\n",c.real(),c.imag());
}
return 0;
} 

1. Often We don’t set up on weblogs, but I would like to condition that this established up really forced me individually to do this! considerably outstanding publish