QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#302917#6300. Best Carry Player 2_fcy_#WA 0ms3772kbC++141.5kb2024-01-11 15:19:472024-01-11 15:19:49

Judging History

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

  • [2024-01-11 15:19:49]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3772kb
  • [2024-01-11 15:19:47]
  • 提交

answer

#include<bits/stdc++.h>
#define int 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];
void outp(vector <int> x)
{
    int flag=0;
    for(int i=x.size()-1;i>=0;i--)
    {
        if(x[i]!=0) flag=1;
        if(flag==1)
        {
            cout<<x[i];
        }
    }
    cout<<endl;
}
void solve()
{
    cin>>n>>k;
    if(k==0)
    {
        cout<<"1\n";
        return;
    }
    for(int i=1;i<=20;i++)
    {
        a[i]=0;
    }
    int tmp=n,cnt=0;
    while(tmp)
    {
        cnt++;
        a[cnt]=tmp%10;
        tmp/=10;
    }
    int fn0=0;
    while(a[fn0+1]==0)
    {
        fn0++;
    }
    int fs9=fn0+k+1;
    //cout<<fn0<<" "<<fs9<<endl;
    if(a[fs9]<9)
    {
        vector <int> ans;
        for(int i=1;i<=fn0;i++)
        {
            ans.pb(0);
        }
        ans.pb(10-a[fn0+1]);
        for(int i=fn0+2;i<=fs9-1;i++)
        {
            ans.pb(9-a[i]);
        }
        outp(ans);
        return;
    }
    while(a[fs9+1]==9)
    {
        fs9++;
    }
    //cout<<"check:"<<fs9<<endl;
    vector <int> ans;
    for(int i=1;i<=fs9-k;i++)
    {
        ans.pb(0);
    }
    ans.pb(10-a[fs9-k+1]);
    for(int i=fs9-k+2;i<=fs9;i++)
    {
        ans.pb(9-a[i]);
    }
    outp(ans);
    return;
}
signed main()
{
    int t;
    cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3744kb

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

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
99991000000
9999910000
9999901000
9999900100
9999900010
9999900001
9000009999900001
99000009999900001
999000009999900001
9999-99999999999999991-999999999999900000000000000000
1

result:

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