-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain11.java
More file actions
41 lines (38 loc) · 947 Bytes
/
Main11.java
File metadata and controls
41 lines (38 loc) · 947 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import java.io.Serializable;
import java.util.Scanner;
/**
* Created by LXF on 2017/8/15.
*/
public class Main11 implements Serializable {
public static int get(int n) {
if (n < 2) {
return 0;
}
if (n == 2) {
return 1;
}
int k = n / 3;
return k + get(n % 3+k);
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int[] n = new int[10];
for (int i = 0; i < 10; i++) {
int c;
if ((c=scanner.nextInt()) != 0) {
n[i] = c;
} else {
break;
}
}
for (int i = 0; i < n.length; i++) {
if (n[i] != 0) {
if (n[i] < 2) {
System.out.println(0);
} else {
System.out.println(get(n[i]));
}
}
}
}
}