QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#590120#8340. 3 SumDBsoleilRE 1ms3888kbC++201.1kb2024-09-25 21:44:322024-09-25 21:44:39

Judging History

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

  • [2024-09-25 21:44:39]
  • 评测
  • 测评结果:RE
  • 用时:1ms
  • 内存:3888kb
  • [2024-09-25 21:44:32]
  • 提交

answer

#include<bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;

const int N=505,M=20005;
const ll MOD=1e9+9;
int n,k,ans;
ll a[N],b[M],mod;
char s[M];

ll getll()
{
    scanf("%s",s);
    ll res=0,len=strlen(s),x=0;
    for(int i=0;i<len;i++) b[i]=s[i]-'0',x=x+(s[i]-'0')%MOD;
    reverse(b,b+len);
    while(len>k)
    {
        for(int i=k;i<len;i++) b[i%k]+=b[i],b[i]=0;
        for(int i=0;i<len;i++) b[i+1]+=b[i]/10,b[i]%=10;
        while(len>0&&b[len-1]==0) len--;
    }
    for(int i=len-1;i>=0;i--) res=(res*10+b[i])%MOD;
    assert(res%MOD==x);
    return res%MOD;
}

bool check(ll x)
{
    return (x==mod||x==mod*2%MOD||x==0);
}

void input()
{
    scanf("%d%d",&n,&k),mod=1;
    for(int i=1;i<=k;i++) mod=mod*10%MOD;
    mod=(mod-1+MOD)%MOD;
    for(int i=1;i<=n;i++) a[i]=getll();
    //for(int i=1;i<=n;i++) cerr<<' '<<a[i];
    //cerr<<endl;
}

void solve()
{
    input();
    for(int i=1;i<=n;i++) for(int j=i;j<=n;j++) for(int k=j;k<=n;k++)
    {
        ll sum=(a[i]+a[j]+a[k])%MOD;
        if(check(sum)) ans++;
    }
    printf("%d\n",ans);
}

int main()
{
    solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4 1
0
1
10
17

output:

3

result:

ok 1 number(s): "3"

Test #2:

score: -100
Runtime Error

input:

500 859
7118711592236878297922359501613604144948355616986970837340677671376753603836852811886591300370143151943368529129749813118476151865844255212534355441611481420938483178075143062691345257288242460282715389758789648541099090735875617822348551942134616963557723055980260082230902505269975518146286...

output:


result: