QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#664660#8340. 3 Sumlllei#WA 47ms5816kbC++142.2kb2024-10-21 21:36:402024-10-21 21:36:42

Judging History

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

  • [2024-10-21 21:36:42]
  • 评测
  • 测评结果:WA
  • 用时:47ms
  • 内存:5816kb
  • [2024-10-21 21:36:40]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=2e4+5;
const int mod1=1e9+7,mod2=1e9+9;
int n,K;
struct bigint
{
    vector<int> num;
    void read()
    {
        string s;
        cin>>s;
        for(int i=0;i<s.size();i++)num.push_back(s[i]-'0');
        reverse(num.begin(),num.end());
    }
    pair<int,int> hs()
    {
        vector<int>tmp(K+1,0);
        for(int i=0;i<num.size();i+=K)
        {
            int flag=1;
            for(int j=i;j<i+K&&j<num.size();j++)
            {
                tmp[j-i]+=num[i];
                if(tmp[j-i]>=10)tmp[j-i]-=10,tmp[j-i+1]++;
                if(tmp[j-i]!=9)flag=0;
            }
            if(flag||tmp[K]==1)
            {
                for(int i=0;i<K;i++)
                {
                    tmp[i]-=9;
                    if(tmp[i]<0)tmp[i]+=10,tmp[i+1]--;
                }
            }
        }
        reverse(tmp.begin(),tmp.end());
        int h1=0,h2=0;
        for(int i=0;i<tmp.size();i++)
        {
            h1=(h1*1LL*10+tmp[i])%mod1;
            h2=(h2*1LL*10+tmp[i])%mod2;
        }
        return {h1,h2};
    }
    pair<int,int> hs2()
    {
        int h1=0,h2=0;
        reverse(num.begin(),num.end());
        for(int i=0;i<num.size();i++)
        {
            h1=(h1*1LL*10+num[i])%mod1;
            h2=(h2*1LL*10+num[i])%mod2;
        }
        return {h1,h2};
    }
}a[N],m1,m2,m3;
pair<int,int>cur[N],h1,h2,h3;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin>>n>>K;
    for(int i=1;i<=n;i++)a[i].read(),cur[i]=a[i].hs();
    m1.num.push_back(0);
    for(int i=0;i<K;i++)m2.num.push_back(9);
    m3.num.push_back(8);
    for(int i=0;i<K-1;i++)m3.num.push_back(9);
    m3.num.push_back(1);
    h1=m1.hs2();
    h2=m2.hs2();
    h3=m3.hs2();
    int ans=0;
    for(int i=1;i<=n;i++)
    for(int j=i;j<=n;j++)
    for(int k=j;k<=n;k++)
    {
        int t1=(cur[i].first*1LL+cur[j].first+cur[k].first)%mod1;
        int t2=(cur[i].second*1LL+cur[j].second+cur[k].second)%mod2;
        pair<int,int> now={t1,t2};
    
        if(now==h1||now==h2||now==h3)
        {
            ans++;
        }
    }
    cout<<ans<<'\n';
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4 1
0
1
10
17

output:

3

result:

ok 1 number(s): "3"

Test #2:

score: -100
Wrong Answer
time: 47ms
memory: 5816kb

input:

500 859
7118711592236878297922359501613604144948355616986970837340677671376753603836852811886591300370143151943368529129749813118476151865844255212534355441611481420938483178075143062691345257288242460282715389758789648541099090735875617822348551942134616963557723055980260082230902505269975518146286...

output:

2925

result:

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