N (3<=n<=9)) only monkeys picked a bunch of peaches, the first monkey secretly up in the middle of the night, the peach evenly divided into n points, found that more than one, it ate the peach, but also take one of them, the second monkey up and put the peach into N points, and one more, it ate the peach, and took one of them, The third and fourth ... The first n monkeys have done so, how many of these peaches are there at least?
Directly on the code:
Package test;
Import Java.util.Scanner;
Public class Monkey {
static int n;
static int sum;
static Scanner Scanner = new Scanner (System. in);
public static void Main (string[] args) {
System. out.println ("" +integer. Max_value);
input ();
output ();
}
Private static void output () {
System. out.println ("" + N);
if (n > 9 | | N < 3) {
System. Out.println ("0");
} else {
int number = n;
For (int i = n + 1; i < Integer. Max_value; i++) {
if (!isok (i, number ))
continue;
else {
System. Out.println ("" + i);
Break ;
}
}
}
}
Private static boolean isOk (int i, int m) {
int count = 0;
While (count < m) {
if (i% (m)! = 1)
return false;
i = i-1-(I/ m);
count++;
}
return true;
}
Private static void input () {
n = scanner.nextint ();
}
}
Huawei Monkey Eats peach problem