-
Notifications
You must be signed in to change notification settings - Fork 0
/
BJ1644.java
32 lines (27 loc) · 797 Bytes
/
BJ1644.java
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
import java.util.*;
public class BJ1644 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
List<Integer> list = new ArrayList<>();
int[] num = new int[N+1];
for (int i = 2; i <= N; i++) {
if (num[i]==-1) continue;
list.add(i);
num[i] = i;
for (int j = 2*i; j <= N; j+=i) {
num[j] = -1;
}
}
int ans = 0;
t: for (int i = 0; i < list.size(); i++) {
int sum=0;
for (int j = i; j < list.size(); j++) {
sum+=list.get(j);
if (sum==N) ans++;
else if (sum>N) continue t;
}
}
System.out.print(ans);
}
}