QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#302980#6300. Best Carry Player 2_fcy_#WA 0ms3704kbC++141.8kb2024-01-11 16:26:122024-01-11 16:26:13

Judging History

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

  • [2024-01-11 16:26:13]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3704kb
  • [2024-01-11 16:26:12]
  • 提交

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[50];
char str[10]={'0','1','2','3','4','5','6','7','8','9'};
char ans[50];
void cal(int k)
{
    //cout<<k<<endl;
    int fn0=0;
    while(a[fn0+1]==0)
    {
        fn0++;
    }
    int fs9=fn0+k+1;
    //cout<<fn0<<" "<<fs9<<endl;
    if(a[fs9]<9)
    {
        ans[fn0+1]=str[10-a[fn0+1]];
        for(int i=fn0+2;i<=fs9-1;i++)
        {
            ans[i]=str[9-a[i]];
        }
        return;
    }
    while(a[fs9+1]==9)
    {
        fs9++;
    }
    //cout<<ans<<endl;
    if(a[fs9-k+1]==0)
    {
        fn0=fs9-k+1;
        while(a[fn0+1]==0)
        {
            fn0++;
        }
        ans[fn0+1]=str[10-a[fn0+1]];
        for(int i=fn0+2;i<=fs9;i++)
        {
            ans[i]=str[9-a[i]];
        }
        //cout<<ans<<" "<<fs9<<" "<<fn0<<endl;
        return;
    }
    //cout<<ans<<endl;
    ans[fs9-k+1]=str[10-a[fs9-k+1]];
    for(int i=fs9-k+2;i<=fs9;i++)
    {
        ans[i]=str[9-a[i]];
    }
    return;
}
void solve()
{
    int sn,sk;
    cin>>sn>>sk;
    if(sk==0)
    {
        cout<<"1\n";
        return;
    }
    for(int i=1;i<=40;i++)
    {
        a[i]=0; ans[i]='0';
    }
    int tmp=sn,cnt=0;
    while(tmp)
    {
        cnt++;
        a[cnt]=tmp%10;
        tmp/=10;
    }
    cal(sk);
    int flag=0;
    for(int i=20;i>=1;i--)
    {
        if(ans[i]!='0')
        {
            flag=1;
        }
        if(flag==1) cout<<ans[i];
    }
    cout<<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: 0ms
memory: 3600kb

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: 3704kb

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
10000000000
9999910000
9999901000
9999900100
9999900010
9999900001
9000009999900001
99000009999900001
999000009999900001
99900000000000000000
1

result:

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