|
||||||||||
Josephus againTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1254 Accepted Submission(s): 367 Problem Description In our Jesephus game, we start with n people numbered 1 to n around a circle, and we eliminated every k remaining person until only one survives. For example, here's the starting configuration for n = 10, k = 2, The elimination order is 2, 4, 6, 8, 10, 3, 7, 1, 9. So 5 survives.The problem: determine the survivor's number , J(n, k). Input There are multiple cases, end with EOF each case have two integer, n, k. (1<= n <= 10^12, 1 <= k <= 1000) Output each case a line J(n, k) Sample Input
Sample Output
Source | ||||||||||
|