QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#504755#9107. Zayin and CountFolity#WA 7ms3596kbC++201.5kb2024-08-04 15:39:482024-08-04 15:39:52

Judging History

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

  • [2024-08-04 15:39:52]
  • 评测
  • 测评结果:WA
  • 用时:7ms
  • 内存:3596kb
  • [2024-08-04 15:39:48]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef __uint128_t ulll;

bool a[10],b[10];
int s[10],nb[10],ma,mb;
ull X,Y;
vector<int> digit(ull X){
    vector<int> res;
    while(X)res.push_back(X%10),X/=10;
    return res;
}
ull pw(ull x,int y){
    ull r=1;
    for(;y;y>>=1){
        if(y&1)r=r*x;
        x=x*x;
    }
    return r;
}
void solve(){
    ma=mb=0;
    for(int i=0;i<10;++i){
        cin>>a[i];
        ma+=a[i],s[i]=(i?s[i-1]:0)+a[i];
    }
    for(int i=0;i<10;++i){
        cin>>b[i];
        if(b[i])nb[mb++]=i;
    }
    cin>>X;
    vector<int> dig=digit(X);
    ull num=0;
    for(int k=1;k<dig.size();++k){
        num+=(ma-(a[0]&&k>1))*pw(ma,k-1);
    }
    for(int k=dig.size()-1;k>=0;--k){
        num+=(s[dig[k]]-1-(a[0]&&k==dig.size()-1))*pw(ma,k);
    }
    //cout<<num<<'\n';
    int k=0;
    ulll sum=0;
    while(sum<=num){
        ++k;
        sum+=(mb-(b[0]&&k>1))*pw(mb,k-1);
    }
    sum-=(mb-(b[0]&&k>1))*pw(mb,k-1);
    vector<int> ans;
    //cout<<k<<' '<<(ull)sum<<'\n';
    for(int i=k-1;i>=0;--i){
        for(int j=b[0]&&i==k-1;j<mb;++j){
            sum+=pw(mb,i);
            if(sum>num){
                ans.push_back(nb[j]);
                break;
            }
        }
        sum-=pw(mb,i);
    }
    for(int x:ans)cout<<x;
    cout<<'\n';
}

int main(){
    ios::sync_with_stdio(0);cin.tie(0);
    int T;
    cin>>T;
    while(T--)solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 7ms
memory: 3596kb

input:

10000
1 0 0 0 1 1 0 0 0 1
0 0 1 0 1 1 1 1 0 0
950595954440050004054505054050
1 0 0 0 1 1 1 1 0 0
1 1 1 0 1 0 0 0 1 1
45467007076660767550460064
1 1 1 1 0 0 0 1 0 0
1 1 0 1 1 0 1 0 0 1
23373171320213300170200722
0 0 0 0 1 1 1 0 1 0
0 0 1 0 0 1 0 1 1 1
558565664666565565558468668484
1 1 0 0 1 0 1 0 1 ...

output:

7244224255446466
7244224255446466
7244224255446466
7244224255446466
7244224255446466
7244224255446466
7244224255446466
7244224255446466
7244224255446466
7244224255446466
7244224255446466
7244224255446466
7244224255446466
7244224255446466
7244224255446466
7244224255446466
7244224255446466
72442242554...

result:

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