QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#504671 | #9107. Zayin and Count | AnotherDayofSun# | AC ✓ | 18ms | 3772kb | C++20 | 1.2kb | 2024-08-04 14:39:36 | 2024-08-04 14:39:37 |
Judging History
answer
#include<bits/stdc++.h>
#define ll __int128
#define For(i,j,k) for(int i=(j);i<=(k);i++)
#define foR(i,j,k) for(int i=(j);i>=(k);i--)
#define vi vector<int>
#define pb push_back
#define pii pair<int,int>
#define mkp make_pair
#define SZ(x) ((int)x.size())
using namespace std;
inline int read() {
char c;int res=0;bool flag=0;
while(c=getchar(),c<48)(c=='-')&&(flag=1);
do res=(res<<3)+(res<<1)+(c^48);
while(c=getchar(),c>47);
flag&&(res=-res); return res;
}
bool a[13],b[13];
char c[1003];
int t,l,p,q,f[13],tot,z[1003],g[13];
ll x;
int main(){
t=read();
while(t--){
x=0;
for(int i=0;i<=9;++i){
a[i]=read();
f[i]=0;
}
for(int i=0;i<=9;++i){
b[i]=read();
}
p=0;
for(int i=1;i<=9;++i){
if(a[i])f[i]=++p;
}
scanf("%s",c);
l=strlen(c);
if(a[0])++p;
for(int i=0;i<l;++i){
x=x*p+f[c[i]^'0'];
}
if(a[0])++x;
q=0;
for(int i=1;i<=9;++i){
if(b[i])g[++q]=i;
}
tot=0;
if(b[0]){
--x;
++q;
while(x){
z[++tot]=g[x%q];
x/=q;
}
if(tot==0)z[++tot]=0;
}
else{
while(x){
if(x%q)z[++tot]=g[x%q];
else z[++tot]=g[q],--x;
x/=q;
}
}
for(;tot;--tot){
printf("%d",z[tot]);
}
printf("\n");
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 18ms
memory: 3772kb
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