-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJ10986_0.java
More file actions
35 lines (28 loc) · 987 Bytes
/
Copy pathJ10986_0.java
File metadata and controls
35 lines (28 loc) · 987 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
package TIL;
import java.util.*;
import java.io.*;
public class J10986_0 {
public static void main(String[] args) throws IOException {
BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
String[] input = buffer.readLine().split(" ");
long N = Integer.parseInt(input[0]);
long key = Integer.parseInt(input[1]);
long[] array = new long[(int)N+1];
long[] cntBox = new long[(int)key];
long total = 0;
long result;
input = buffer.readLine().split(" ");
for(long i = 1; i <= N; i++) {
array[(int)i] = Integer.parseInt(input[(int)i-1]);
total += array[(int)i];
cntBox[(int)(total % key)] +=1;
}
result = (int)cntBox[0];
for(long i = 0; i <key; i++){
if(cntBox[(int)i]>1){
result += (cntBox[(int)i]*(cntBox[(int)i]-1))/2;
}
}
System.out.println(result);
}
}