QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#302861#6300. Best Carry Player 2_fcy_#WA 1ms3424kbC++141.1kb2024-01-11 14:19:142024-01-11 14:19:14

Judging History

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

  • [2024-01-11 14:19:14]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3424kb
  • [2024-01-11 14:19:14]
  • 提交

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 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;
    }
    for(int i=1;i<=20;i++)
    {
        vector <int> ans;
        ans.pb(10-a[i]);
        if(a[i]==0) continue;
        for(int j=i+1;j<=i+k-1;j++)
        {
            ans.pb(9-a[j]);
           // cout<<i<<" "<<j<<" "<<a[j]<<endl;
        }
        if(a[i+k]==9) continue;
        int qian=0;
        //cout<<i<<" ";
        for(int j=ans.size()-1;j>=0;j--)
        {
            if(ans[j]!=0) qian=1;
            if(qian==1)
            cout<<ans[j];
        }
        for(int j=1;j<=i-1;j++)
        {
            cout<<"0";
        }
        cout<<endl;
        break;
    }
}
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: 3424kb

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: 1ms
memory: 3416kb

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

result:

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