The Abominable Bride
All submissions for this problem are available.
Everyone knows the famous detective Sherlock. He has been handed over a new case of "The Abominable Bride". Each night she kills N people but to irritate
Sherlock she leaves exactly one people. The way she kills the people is somewhat strange. She makes 1 to N people stand in a line and starts killing
them. But, in the line when she kills the first person, there's time for the person standing next in line to run away at the end of the line.Again she kills the first
person and the second one next to him runs to the last of the line. In this way after killing, there is exactly one person standing in the line who is saved and he
runs to Sherlock to explain the situation each night. Help Sherlock find out the person that will be saved at the end of the massacre.
Constraints and Subtasks
Subtask 2: 20 points
Subtask 2: 80 points
- original constraints
- The first line of input contains a single integer T denoting the number of test cases.
- The first and only line of each test case contains an integer N denoting the number of people standing in line.
For each test case, output the person who will be meeting Sherlock at the end of the massacre.
Input: 5 2 4 6 9 12 Output: 2 4 4 2 8
For the 2nd test case, she kills 1 and 2 goes at the end of line i.e., 3 4 2. Then she kills 3rd and 4th goes at the end of line i.e. 2 4. Then she kills 2 and
ultimately 4th is the lone survivour.
|Tags||ad-hoc, adi28galaxyak, cdva16, easy, implementation|
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, CLOJ, FS|
Fetching successful submissions