QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#347783#8340. 3 Sumucup-team346#WA 19ms56196kbC++141.4kb2024-03-09 15:24:252024-03-09 15:24:28

Judging History

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

  • [2024-09-20 10:20:30]
  • hack成功,自动添加数据
  • (/hack/848)
  • [2024-03-18 21:48:05]
  • hack成功,自动添加数据
  • (/hack/579)
  • [2024-03-18 21:45:33]
  • hack成功,自动添加数据
  • (/hack/578)
  • [2024-03-09 15:24:28]
  • 评测
  • 测评结果:WA
  • 用时:19ms
  • 内存:56196kb
  • [2024-03-09 15:24:25]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n,K;
#define M 505
#define N 100005
char A[M][N];
const ll P = 1e17+19;
ll B[M];
int cnt = 0;
int tmp[M];
int main(){
    cin>>n>>K;
    for(int i=1;i<=n;i++){
        scanf("%s",A[i]+1);
        int len = strlen(A[i] + 1);
        reverse(A[i]+1,A[i]+1+len);
        for(int j=1;j<=K+1;j++)tmp[j]=0;
        for(int j=1;j<=len;j+=K){
            for(int k=1;k<=K;k++){
                int v = tmp[k] + (j+k-1 > len ? 0 : (int)(A[i][j+k-1]-'0'));
                tmp[k] = v%10;
                tmp[k+1] += v/10;
            }
            while(tmp[K+1]){
                assert(tmp[K+1] == 1);
                tmp[K+1] = 0;
                int k=1;
                for(;k<=K && tmp[k]==9;k++)
                    tmp[k] = 0;
                tmp[k]++;
            }
        }
        int flg = 1;
        for(int j=1;flg && j<=K;j++)
            if(tmp[j] != 0)flg = 0;
        cnt += flg;
        for(int j=K;j>=1;j--)
            B[i] = (10*B[i]+tmp[j])%P;
    }
    int a=0,b=0;
    for(int i=1;i<=K;i++)
        a=(10ll*a+9)%P;
    b=2*a%P;
    unordered_map<ll,int> pos;
    ll ans = 1ll*(cnt+2)*(cnt+1)*cnt/6;
    for(int i=n;i>=1;i--){
        pos[B[i]]++;
        for(int j=i;j>=1;j--){
            ans += pos[(P+P+a-B[i]-B[j])%P];
            ans += pos[(P+P+b-B[i]-B[j])%P];
        }
    }
    cout<<ans<<endl;
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 5740kb

input:

4 1
0
1
10
17

output:

3

result:

ok 1 number(s): "3"

Test #2:

score: -100
Wrong Answer
time: 19ms
memory: 56196kb

input:

500 859
7118711592236878297922359501613604144948355616986970837340677671376753603836852811886591300370143151943368529129749813118476151865844255212534355441611481420938483178075143062691345257288242460282715389758789648541099090735875617822348551942134616963557723055980260082230902505269975518146286...

output:

1

result:

wrong answer 1st numbers differ - expected: '0', found: '1'