QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#220901#6300. Best Carry Player 2YoungWA 0ms3680kbC++141.5kb2023-10-20 22:51:022023-10-20 22:51:02

Judging History

This is the latest submission verdict.

  • [2023-10-20 22:51:02]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3680kb
  • [2023-10-20 22:51:02]
  • Submitted

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
string s,s1,ss;
void solve(){
    int x,kk;
    cin>>x>>kk;
    s="";
    s1="";
    while(x>0){
        int g=x%10;
        x/=10;
        s+=('0'+g);
    }
    for(int i=1;i<40;i++){
        s+='0';
        s1+='0';
    }
    if(kk==0){
        int cnt=0;
        for(int i=0;i<s.length();i++){
            if(s[i]!='9'){
                break;
            }
            cnt++;
        }
        cout<<1;
        for(int i=1;i<=cnt;i++) cout<<0;
        cout<<'\n';return ;
    }
    if(s[kk]=='9'){
        int g=kk;
        while(s[g]=='9') g++;
        g--;
        for(int i=g;i>=0;i--){
            // cout<<s[i]<<' '<<i<<'|';
            kk-=1;
            s1[i]=(9+'0'+'0'-s[i]);
            if(kk==0){
                s1[i]=(10+'0'+'0'-s[i]);
                break;
            }
        }
    }
    else{
        // cout<<kk<<'\n';
        for(int i=1;i<kk;i++){
            s1[i]=(9+'0'+'0'-s[i]);
        }
        s1[0]=(10+'0'+'0'-s[0]);
        kk=0;
    }
    // reverse(s1.begin(),s1.end());
    int ff=0;
    for(int i=s1.length()-1;i>=0;i--){
        if(s1[i]!='0') ff=1;
        if(ff==1) cout<<s1[i];
    }
    cout<<'\n';
    
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    int t;
    cin>>t;
    while(t--){
        solve();
    }
    return 0;
}
// 4
// 12345678 0
// 12345678 5
// 12345678 18
// 990099 5

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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:

100000
10000
1000
100
10
1
900001
9900001
99900001
999900001
9999:00000
9999910000
9999901000
9999900100
9999900010
9999900001
9000009999900001
99000009999900001
999000009999900001
89999999999999999:
1000000000000000000

result:

wrong answer 11th lines differ - expected: '10000000001', found: '9999:00000'