FightProblem code: TGPA03 |
We, the team members of Conscientia regard ourselves as very intelligent and hardworking people. So when the time came to distribute the responsibility for the food stalls we all knew that the one responsible would gain maximum benefits. That started a fight. Now being very intelligent I proposed that we come to a conclusion based on some random procedure. So I proposed that we all should stand sequentially and remove every kth person from the line until only one is left. Everyone thought this to be a really good idea as only I, being the only one from CS background knew that this is not at all random. Now that I have been chosen, you have to basically prove to the team that I made a fool of them.
Input Format
The first line contains the number of test cases, t. For each test case, a single line contains a single number n denoting the number of people in the team.
Output Format
For each test case the position where I stood to get the responsibility for the food stalls in a seperate line.
Limits
0<=n<=10^8Sample Input: 2 10 3 20 5 Sample Output: 4 7
| Author: | theta |
| Date Added: | 26-02-2010 |
| Time Limit: | 3 sec |
| Source Limit: | 50000 Bytes |
| Languages: | C, CLOJ, CPP 4.3.2, F#, GO, PERL6, PYTH 3.1.2, TEXT |
Comments

Fetching successful submissions

please give the range of t
please give the range of t and k
1<=k<=n 1<=t<=10
1<=k<=n
1<=t<=10
what happens whent he number
what happens whent he number of remaining people are less than k ?
does removing the kth person
does removing the kth person mean removing the people standing in positions that are multiple of k ?
The second number in each
The second number in each line denotes the value of k
@vivek when the n left is
@vivek
when the n left is less than k, then also the count goes on circularly with k
yes
@vivek when the no left is
@vivek
when the no left is less than k, then also the count goes on circularly with k
yes