QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#547407#9107. Zayin and Countwzxtsl#RE 0ms0kbC++171.6kb2024-09-04 21:25:072024-09-04 21:25:08

Judging History

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

  • [2024-09-04 21:25:08]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-09-04 21:25:07]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define For(i,j,k) for (int i=(j);i<=(k);i++)
#define rof(i,j,k) for (int i=(j);i>=(k);i--)
#define ull unsigned long long
#define lowbit(x) ((x)&(-(x)))
#define PII pair<int,int>
#define int long long
#define endl "\n"
#define ls rt<<1
#define rs rt<<1|1
typedef long long ll;
const int mod = 998244353;
const int N=2e2+7;
int n,m,ca,cb;
int a[N],b[N],op;
int x,len;
int s[N];
int p[10][21];
void poow()
{
    For(i,2,9)
    {
        int res=1;
        For(j,0,20)
            p[i][j]=res,res*=i;
    }
}
void solve(){
    ca=cb=len=n=0;
    For(i,0,9)
    {
        cin>>op;
        if(op) a[++ca]=i;
    }
    For(i,0,9)
    {
        cin>>op;
        if(op) b[++cb]=i;
    }    
    cin>>x;
    int tp=x;
    while(tp)
    {
        s[++len]=tp%10;
        tp/=10;
    }
    rof(i,len,1)
    {
        n+=(lower_bound(a+1,a+1+ca,s[i]-1)-a);
    }
    if(a[1]!=0) n+=p[ca][len-1];//cout<<n<<"!";
    
    if(b[1]==0)
    {
        int k=0;
        while(p[cb][k]<n) k++;
        k--;
        while(k>=0)
        {
            cout<<b[n/p[cb][k]+1];
            n=n%p[cb][k];
            k--;
        }
    }
    else{
        int k=0;
        while((p[cb][k+1]-1)/(cb-1)<n) k++;
        k--;
        while(k>=0)
        {
            cout<<b[n/((p[cb][k+1]-1)/(cb-1))+1];
            n=n%(p[cb][k+1]-1)/(cb-1);
            k--;
        }        
    }
}
signed main(){
    fast;
    int t=1;
    cin>>t;
    poow();
    while(t--){
        solve();
    }
    //system("pause");
}

详细

Test #1:

score: 0
Runtime Error

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:


result: