QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#504601#9101. Zayin and BusCheek_support#TL 0ms0kbC++202.0kb2024-08-04 14:00:552024-08-04 14:00:56

Judging History

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

  • [2024-08-04 14:00:56]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-08-04 14:00:55]
  • 提交

answer

#include <bits/stdc++.h>
#define rep(i,j,k) for(int i=j;i<=k;i++)
#define INT __int128
using namespace std;
int read(){
    char ch=getchar();int x=0,f=1;
    for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=-1;
    for(;ch>='0'&&ch<='9';ch=getchar())x=x*10+ch-'0';
    return f*x;
}
template<typename T> void write(T x){
    if(x>9)write(x/10);
    putchar(x%10+'0');
}
template<typename T> void Write(T x){
    write(x);putchar('\n');
}
int a[20],b[20];
int rka[20],rkb[20];
int tpa[20],tpb[20];
char Num[110];
char Ans[110];
INT poww(INT n,INT m){
    INT ret=1;INT temp=n;INT tmp=m;
    while(tmp){
        if(tmp&1)ret*=temp;
        temp*=temp;
        tmp>>=1;
    }
    return ret;
}
int main(){
    int T=read();
    while(T--){
        int tot1=0;
        rep(i,0,9){
            a[i]=read();
            tot1+=(a[i]==1);
            if(a[i]){
                rka[i]=tot1;
                tpa[tot1]=i;
            }
        }

        int tot2=0;
        rep(i,0,9){
            b[i]=read();
            tot2+=(b[i]==1);
            if(b[i]){
                rkb[i]=tot2;
                tpb[tot2]=i;
            }
        }

        scanf("%s",Num+1);
        int len=strlen(Num+1);

        __int128 Tim=0;
        rep(i,1,len){
            int x=Num[i]-'0';
            int rk=rka[x];
            Tim+=poww(tot1,len-i)*(rk-1);
        }

        int anslen=1;
        while(poww(tot2,anslen-1)<Tim)anslen++;
        rep(i,1,anslen){
            __int128 tmp=poww(tot2,anslen-i);
            int cnt=0;
            while(Tim-tmp>=0){
                Tim-=tmp;
                cnt++;
            }
            int x=tpb[cnt+1];
            Ans[i]=x+'0';
        }

        rep(i,1,anslen)putchar(Ans[i]);
        putchar('\n');
    }
    return 0;
}
/*
4
1 0 1 0 0 0 0 0 0 0
1 1 0 0 0 0 0 0 0 0
20
0 1 1 0 0 0 0 0 0 0
1 0 0 1 0 0 0 0 0 0
2
0 1 1 0 0 0 0 0 0 0
0 1 0 1 0 0 0 0 0 0
12
0 0 1 1 0 0 0 0 0 0
0 1 0 1 0 1 0 0 0 0
32223

*/

详细

Test #1:

score: 0
Time Limit Exceeded

input:

14
1
1
1
2
1
3
2
1
1 1
2
1
1 2
2
1
2 1
2
1
1 3
2
1
3 1
2
1
1 4
2
1
4 1
3
1 1
1 1 1
3
1 2
1 1 1
3
1 1
1 3 2
3
1 2
1 3 2

output:


result: