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:||C, CPP14, JAVA, PYTH, PYTH 3.6, 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, PYP3, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.