GRIDPNT - Grid points
There's a Cartesian lattice with 0<=x,y<=n. Given one point (x1, y1>0) in this lattice rotating clockwise as little as possible around the origin find the next point (x2, y2). The given and searched points mustn't have another point between the origin (0, 0) and this point itself.
x1, y1, x2, y2 are non-negative integers.
Score is source length.
Input
In the first line the number T (T<100) of test cases.
Then T lines with the space-separated n (1<=n<=50), x1 and y1.
Output
For each test case the space-separated x2 and y2.
Example
Input: 3
1 1 1
5 3 2
50 48 49 Output: 1 0
5 3
49 50
hide comments
XeRoN!X:
2012-08-07 19:43:55
Sol. submitted at shorten. Lets see how much Jander is able to reduce now.
|
|
HWK:
2012-08-07 19:43:55
@XeRon!X: Very nice solution with Bash. But you could save more bytes. I reached 108 without changing your algo. ;-)
|
|
XeRoN!X:
2012-08-07 19:43:55
Edit: 106 now :) Last edit: 2011-06-26 09:41:56 |
|
HWK:
2012-08-07 19:43:55
@XeRon!X: In SHORTEN the best solution requires 107 bytes with Perl. (https://www.spoj.pl/SHORTEN/problems/GRIDPNT/) |
|
Piotr:
2012-08-07 19:43:55
[edit] Got it! Now to find a way to reduce the lenght of the code.... Last edit: 2011-06-09 13:45:35 |
|
HWK:
2012-08-07 19:43:55
@Piotr: Almost correct, only 5 mistakes. There you print the same output as in the line before. ;-) |
|
HWK:
2012-08-07 19:43:55
2 0 0, 2 1 0 (y must be >0) and 2 0 2 (0 1 lies between 0 2 and 0 0) are not possible.
|
|
Anshu Avinash:
2012-08-07 19:43:55
2 0 0 is not possible.(x1,y1>0) |
|
XeRoN!X:
2012-08-07 19:43:55
Rotation > 0 or >= 0 ??
|
|
HWK:
2012-08-07 19:43:55
@numerix: That's right. It's changed now.
|
Added by: | HWK |
Date: | 2011-05-24 |
Time limit: | 9.989s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All |