QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#302951#6300. Best Carry Player 2_fcy_#WA 1ms3668kbC++141.8kb2024-01-11 15:59:512024-01-11 15:59:52

Judging History

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

  • [2024-01-11 15:59:52]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3668kb
  • [2024-01-11 15:59:51]
  • 提交

answer

#include<bits/stdc++.h>
#define int unsigned long long
#define p(a,b) make_pair(a,b)
#define pb push_back
using namespace std;
const int MAXN=5e5+10;
const int mod=1e9+7;
int n,k,a[30];
int cal(int k)
{
    //cout<<k<<endl;
    int fn0=0,ans=0;
    while(a[fn0+1]==0)
    {
        fn0++;
    }
    int fs9=fn0+k+1;
    //cout<<fn0<<" "<<fs9<<endl;
    if(a[fs9]<9)
    {
        int base=pow(10,fn0);
        ans=(10-a[fn0+1])*base;
        base*=10;
        //cout<<a[fn0+1]<<" "<<ans<<endl;
        for(int i=fn0+2;i<=fs9-1;i++)
        {
            ans+=(9-a[i])*base;
            base*=10;
        }
        return ans;
    }
    while(a[fs9+1]==9)
    {
        fs9++;
    }
    //cout<<"check:"<<fs9<<endl;
    int base=pow(10,fs9-k);
    ans=0;
    //cout<<ans<<endl;
    if(a[fs9-k+1]==0)
    {
        fn0=fs9-k+1;
        while(a[fn0+1]==0)
        {
            fn0++;
        }
        base=pow(10,fn0);
        ans+=base*(10-a[fn0+1]);
        base*=10;
        for(int i=fn0+2;i<=fs9;i++)
        {
            ans+=base*(9-a[i]);
            base*=10;
        }
        //cout<<ans<<" "<<fs9<<" "<<fn0<<endl;
        return ans+cal(k-(fs9-fn0));
    }
    ans+=base*(10-a[fs9-k+1]);
    //cout<<ans<<endl;
    base*=10;
    for(int i=fs9-k+2;i<=fs9;i++)
    {
        ans+=base*(9-a[i]);
        base*=10;
    }
    return ans;
}
void solve()
{
    int sn,sk;
    cin>>sn>>sk;
    if(sk==0)
    {
        cout<<"1\n";
        return;
    }
    for(int i=1;i<=20;i++)
    {
        a[i]=0;
    }
    int tmp=sn,cnt=0;
    while(tmp)
    {
        cnt++;
        a[cnt]=tmp%10;
        tmp/=10;
    }
    cout<<cal(sk)<<endl;
}
signed main()
{
    int t;
    cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}
/*
6
990090001000 4
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4
12345678 0
12345678 5
12345678 18
990099 5

output:

1
54322
999999999987654322
9910

result:

ok 4 lines

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3668kb

input:

21
999990000099999 0
999990000099999 1
999990000099999 2
999990000099999 3
999990000099999 4
999990000099999 5
999990000099999 6
999990000099999 7
999990000099999 8
999990000099999 9
999990000099999 10
999990000099999 11
999990000099999 12
999990000099999 13
999990000099999 14
999990000099999 15
999...

output:

1
10000
1000
100
10
1
900001
9900001
99900001
999900001
10000000001
9999910000
9999901000
9999900100
9999900010
9999900001
9000009999900001
99000009999900001
999000009999900001
6802913523534266272
1

result:

wrong answer 1st lines differ - expected: '100000', found: '1'