QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#661716#8932. BingoCorycle#WA 1ms5684kbC++142.9kb2024-10-20 17:45:092024-10-20 17:45:11

Judging History

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

  • [2024-10-20 17:45:11]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5684kb
  • [2024-10-20 17:45:09]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
const int maxn=4e6+5;
int ptr,ed;
char n[maxn];
char nn[maxn];
void add(__int128 tba)
{
    int p = ed-1;
    for(;p>=ptr;--p)
    {
        tba=tba+(n[p]-'0');
        n[p] = (char)(tba%10+'0');
        tba=tba/10;
    }
    while(tba!=0)
    {
        ptr--;
        n[ptr]=(char)(tba%10+'0');
        tba=tba/10;
    }
}
string ts(int t)
{
    stringstream ss;
    ss<<t;
    string tt;
    ss>>tt;
    return tt;
}
void mian()
{
    ptr = 1145;
    int m;
    cin>>(n+ptr)>>m;

    for(int i=0;i<=30;++i)
    {
        n[--ptr] = '0';
    } 

    string M=ts(m);

    for(ed=ptr;n[ed]!='\0';++ed);

    add(1);

    for(int i=ptr;i<ed;++i)
    {
        int j = i;
        bool ist = true;
        for(auto k:M)
        {
            if(n[j++]!=k) ist = false;
        }
        if(ist)
        {
            bool top = false;
            for(int i=ptr;i<ed;++i)
            {
                if(n[i]!='0') top=true;
                if(top) cout<<n[i];
            }
            cout<<"\n";
            return;
        }
    }

    string fuck = "0";
    for(int i=1;i<=18;++i) fuck.push_back(n[ed-19+i]);

    int lgm = M.size();

    string ff = "1";
    for(int i=1;i<=18;++i) ff.push_back('9'+1);

    for(int i=0;i<=19-lgm;++i)
    {
        string F = fuck;
        for(int j=0;j<lgm;++j)
        {
            F[i+j] = M[j];
        }
        //cout<<"tmp2 "<<F<<endl;

        if(F>fuck)
        {
            ff = min(ff,F);
        }

        for(int j=lgm;i+j<19;++j)
        {
            F[i+j]='0';
        }
        //cout<<"tmp3 "<<F<<endl;
        
        if(F>fuck)
        {
            ff = min(ff,F);
        }

        //cout<<"f "<<F<<endl;
    }

    for(int i=1;i<=19-lgm;++i)
    {
        string F = fuck;
        F[0]='1';
        for(int j=0;j<lgm;++j)
        {
            F[i+j] = M[j];
        }
        //cout<<"tmp2 "<<F<<endl;

        if(F>fuck)
        {
            ff = min(ff,F);
        }

        for(int j=lgm;i+j<19;++j)
        {
            F[i+j]='0';
        }
        //cout<<"tmp3 "<<F<<endl;
        
        if(F>fuck)
        {
            ff = min(ff,F);
        }

        //cout<<"f "<<F<<endl;
    }

    __int128 orz = 0;
    
    for(int i=0;i<19;++i)
    {
        orz=(orz*10)+(ff[i]-fuck[i]);
    }


    __int128 md=0;
    for(int i=ptr;i<ed;++i)
    {
        md = ((md*10) + n[i]-'0')%m;
    }

    md = (m*10-md)%m;

    //cout<<"shit "<<(int)md<<endl;

    md=min(md,orz);

    add(md);

    bool top = false;

    for(int i=ptr;i<=ed;++i)
    {
        if(n[i]!='0') top=true;
        if(top) cout<<n[i];
    }

    cout<<'\n';

}
signed main()
{
    ios::sync_with_stdio(0);
    int t;
    cin>>t;
    for(int i=1;i<=t;++i)
    {
        mian();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 5684kb

input:

6
7 3
12 3
9 10
249 51
1369 37
2 1

output:

9

result:

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