Chef Food Ordering
All submissions for this problem are available.
Chef has prepared n food items numbered from 1 to n.
But he will not supply the food in order.Instead he arranged the food
items in a circle and
he will supply every kth food item.(supply means to remove the food item from
Consider for example n = 5, k = 2,
1 2 3 4 5.
1st person gets 2nd item
2nd person gets 4th item
3rd person gets 1st item
4th person gets 5th item
5th person gets 3rd item
His manager questioned him, which food item qi'th person would get.
There are Q questions from his manager.Chef has to answer all the Q questions.
So chef need your help to find out the answer.
n k Q q1 q2 q3 ... qn
Output Formata1 a2 a3 ... an
Input: 5 2 5 1 2 3 4 5 0 0 Output: 2 4 1 5 3 Constraints: 1 <= k <= n <= 100000 Q <= n 1 <= qi <= n for all 1 <= i <= Q There will be not more than 100 test cases. Explanation: This test case is from the example explained above.
|Time Limit:||0.16092 sec|
|Source Limit:||50000 Bytes|
|Languages:||ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.3.2, CPP 6.3, CPP14, CS2, D, ERL, FORT, FS, GO, HASK, ICK, ICON, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, NODEJS, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYTH, PYTH 3.5, RUBY, SCALA, SCM guile, SCM qobi, ST, TCL, TEXT, WSPC|
Fetching successful submissions
If you are still having problems, see a sample solution here.