//Topcoder SRM 567 DIV 2, L1 NinjaTurtles
import java.util.*;
import java.math.*;
//rename the class name before submit
//NinjaTurtles
public class NinjaTurtles {
public static void main(String[] args) {
System.out.println(
//
new NinjaTurtles().countOpponents(
122, 21
));
}
public int countOpponents(int P, int K) {
int N = 3;
while (true) {
int tot = (N / K) * 3 + (N / 3);
if (tot == P)
return N;
if (tot > P)
break;
N++;
}
return -1;
}
}
No comments:
Post a Comment