All submissions for this problem are available.
K children are sitting in a circular fashion.
The children are numbered from 1 to K in clockwise order. Each of them has a card with an integer (non-zero) on it. The game starts from the Nth child, who tells the integer on the card and jumps out of the circle. Let I denote that integer. If I is positive, Ith child to the left will be next to jump. If I is negative, Ith child to the right will be next to jump.
The game lasts until all children have jumped out of the circle.
During the game, the ith child jumping out will get candies equal to the number of positive integers that perfectly divide i.
For e.g. first child that jumps out gets 1 candy only.
Who gets the most candies?
There are T test cases in the input.
Each test case starts with two integers K and N on the first line.
The next K lines contains the names of the children and the integers I on his/her card.
Output for each test case (in specified format):- Case number: name of the luckiest child and the number of candies he/she gets. If ties occur, always choose the child who jumps out of the circle first.
0 < T ≤ 5
0 < K ≤ 500,000
1 ≤ N ≤ K
|name| ≤ 10
0 < |I| ≤ 108
1 4 2 Tom 2 Jerry 4 Mickey -1 Donald 1
Case 1:Donald 3
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, CS2, PYP3|
Fetching successful submissions
If you are still having problems, see a sample solution here.