Submit | All submissions | Best solutions | Back to list |
CMIYC - Catch Me If You Can |
One day two friends Rocko and Hunter go to playground which in shape of regular connected polygon. They were confused about which game to play, suddenly Rocko comes with an idea of playing Catch Me If You Can. In this game what they are supposed to do is to start from a check post in the ground and then simultaneously move in opposite direction with different speeds (Rocko with speed x and Hunter with speed 2x). In each move they can hop to another check post. Note each check post is unit distance on periphery of polygon from another check post.
Now what they want to find is at what distance from start point will they meet. Since both Rocko and Hunter are bit poor in mathematics, so they want your help to find that distance for them.
Note they can't meet in middle of two check posts.
For example: suppose size of ground is 2 units.
1 move: Rocko: 1 → 2, and Hunter: 1 → 2 → 1
2 move: Rocko: 2 → 1, and Hunter: 1 → 2 → 1
Thus, 1 is meeting point and its distance from start is 1 - 1 = 0
Input
There is a single positive integer T (T <= 100000) on the first line of input which corresponds to the number of tests cases. Then T lines follow, each containing a number N which represents size of polygon field, where 0 < N <= 10^17
Output
T lines containing distance of meeting point from start.
Example
Input: 2 1 2 Output: 0 0
Added by: | aman jain |
Date: | 2014-02-19 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
Resource: | Own Problem |
hide comments
2020-03-02 23:23:56
easy peasy... |
|
2014-02-24 20:05:37 NISHANT RAJ
finally moved to tutorial.. |
|
2014-02-24 18:39:17 Francky
It is tutorial stuff ; moved. |
|
2014-02-24 00:44:34 Jacob Plachta
This problem probably belongs in Tutorial. |
|
2014-02-21 21:08:29 abdelkarim
@RIVU DAS the same here :D |
|
2014-02-25 08:38:12 NISHANT RAJ
it should be moved to tutorial.. |
|
2014-02-21 16:48:29 Bhavik
too easy... |
|
2014-02-21 09:11:18 aqfaridi
my 400th.. :) |
|
2014-02-19 15:01:31 RIVU DAS
Reminded me of the movie!!! :p |