QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#465834 | #9107. Zayin and Count | grass8cow# | AC ✓ | 15ms | 3668kb | C++17 | 930b | 2024-07-07 10:48:16 | 2024-07-07 10:48:16 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
char c[70];
int t1,t2,r1[13],r2[13],b1[13],b2[13];
void sol(){
t1=t2=0;
for(int i=0,a;i<10;i++){
scanf("%d",&a);
if(a)r1[i]=t1,b1[t1]=i,t1++;
else r1[i]=-1;
}
for(int i=0,a;i<10;i++){
scanf("%d",&a);
if(a)r2[i]=t2,b2[t2]=i,t2++;
else r2[i]=-1;
}
scanf("%s",c);__int128 x=0,w=1;int L=strlen(c);
for(int i=L-1;i>=0;i--){
x=x+w*r1[c[i]-'0'];
if(r1[0]==-1&&w!=1)x+=w;
w*=t1;
}
L=0;
if(r2[0]==-1){
w=t2;
L=1;
while(x>=w)L++,x-=w,w*=t2;
for(int i=0;i<L;i++)c[i]='0'+b2[x%t2],x/=t2;
}
else{
L=0;while(x)c[L++]='0'+b2[x%t2],x/=t2;
if(L==0)L=1,c[0]='0';
}
for(int i=L-1;i>=0;i--)putchar(c[i]);
puts("");
}
int main(){
int T;scanf("%d",&T);while(T--)sol();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 15ms
memory: 3668kb
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:
52755244567262766742575722 41990991999414091249949 101364364636933104003903 57558888789255872922852552 757222758857875785288225787822 761161760076076167101117776167 56666586555668686566656586856566686658 15611661611611111511116116661611616155 505885888775005550558080707878 3912911219633669993999199 ...
result:
ok 10000 lines