Topic description
A sports school in the training gap, the teacher in order to strengthen the students ' physical fitness and for fair treatment, organized a mental plus physical training game. The rule of the game is this: the teacher let the students all n people sit in a circle. The first person first uttered the number 1. Next, sitting on his left side of the classmate to say the next number 2. The following one students from the last classmate said the number down two she used out, that is to say, 4. The next classmate to count down three, say 7. by analogy. If one of the students is wrong, he will do the same push-ups as the sum of all the numbers that the first classmate has uttered (the sum of the first student said T numbers).
to keep the numbers from getting too big, the teacher rules that when you count to k-1 in your mind, the next number starts at 0. For example, when K=13, the first few numbers the students reported were:
1, 2, 4, 7, 11, 3, 9, 3, 11, 7. The
game for a while, the first m classmate in the T said the number of times when said wrong, then he will do how many push-ups. The first row of the
input
input contains three integer n,k,t, where the meaning of N and K is as described above, T represents the number of digits that the first classmate has uttered so far.
Sample Input
3 3
Output
outputs a row that contains an integer that represents the number of push-ups that the classmate does.
Sample Output
import Java.util.Scanner;
public class Main {public static void main (string[] args) {Scanner Scanner = new Scanner (system.in);
int n = scanner.nextint ();
int k = Scanner.nextint ();
int T = Scanner.nextint ();
Scanner.close ();
int sum = 0;
Boolean end = false; while (true) {for (int j = 0, num = 1, count = 0;; j +) {if (j% n = 0) {Co
unt++;
sum + = num;
} if (count = = T) {System.out.println (sum);
end = true;
Break
num = (num + j + 1)% K;
} if (end) {break; }
}
}
}