QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#630554 | #8340. 3 Sum | lionel_code | TL | 108ms | 58120kb | Java11 | 1.0kb | 2024-10-11 19:11:31 | 2024-10-11 19:11:32 |
Judging History
answer
import java.math.BigInteger;
import java.util.*;
public class Main {
//final static int MOD=(int)1e9+7;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n=sc.nextInt();
int k=sc.nextInt();
StringBuffer M=new StringBuffer();
for (int i = 0; i < k; i++) {
M.append(9);
}
BigInteger m=new BigInteger(M.toString());
String []s=new String[n];
BigInteger []a=new BigInteger[n];
for (int i = 0; i < n; i++) {
s[i]=sc.next();
a[i]=new BigInteger(s[i]);
a[i].mod(m);
}
int ans=0;
for (int i = 0; i < n; i++) {
for (int j = 0; j <= i; j++) {
for (int l = 0; l <= j; l++) {
if(a[i].add(a[j].add(a[l])).mod(m).equals(new BigInteger("0"))){
ans++;
}
}
}
}
System.out.println(ans);
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 108ms
memory: 58120kb
input:
4 1 0 1 10 17
output:
3
result:
ok 1 number(s): "3"
Test #2:
score: -100
Time Limit Exceeded
input:
500 859 7118711592236878297922359501613604144948355616986970837340677671376753603836852811886591300370143151943368529129749813118476151865844255212534355441611481420938483178075143062691345257288242460282715389758789648541099090735875617822348551942134616963557723055980260082230902505269975518146286...