-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAgc023A.java
More file actions
31 lines (30 loc) · 1.01 KB
/
Copy pathAgc023A.java
File metadata and controls
31 lines (30 loc) · 1.01 KB
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
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Agc023A {
public static void main(String[] args)throws Exception {
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(input.readLine());
StringTokenizer tokn = new StringTokenizer(input.readLine());
long [] values = new long [n];
for (int i = 0; i < n; i++) {
if (i == 0){
values[i] = Integer.parseInt(tokn.nextToken());
}else{
values[i] = values[ i - 1] + Integer.parseInt(tokn.nextToken());
}
}
int count = 0;
for (int i = 0; i < n; i++) {
for (int j = i; j < n; j++) {
long sum = values[j];
if (i != 0){
sum -= values[i - 1];
}
if (sum == 0)
count++;
}
}
System.out.println(count);
}
}