QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#630554#8340. 3 Sumlionel_codeTL 108ms58120kbJava111.0kb2024-10-11 19:11:312024-10-11 19:11:32

Judging History

你现在查看的是最新测评结果

  • [2024-10-11 19:11:32]
  • 评测
  • 测评结果:TL
  • 用时:108ms
  • 内存:58120kb
  • [2024-10-11 19:11:31]
  • 提交

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);
    }
}

详细

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...

output:


result: