QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#547398 | #9107. Zayin and Count | wzxtsl# | TL | 0ms | 0kb | C++17 | 1.6kb | 2024-09-04 21:17:31 | 2024-09-04 21:17:32 |
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 pow(int a,int p)
{
int res=1;
while(p--)
res=res*a;
return res;
}
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+=pow(ca,len-1);//cout<<n<<"!";
if(b[1]==0)
{
int k=0;
while(pow(cb,k)<n) k++;
k--;
while(k>=0)
{
cout<<b[n/pow(cb,k)+1];
n=n%pow(cb,k);
k--;
}
}
else{
int k=0;
while((pow(cb,k+1)-1)/(cb-1)<n) k++;
k--;
while(k>=0)
{
cout<<b[n/((pow(cb,k+1)-1)/(cb-1))+1];
n=n%(pow(cb,k+1)-1)/(cb-1);
k--;
}
}
}
signed main(){
fast;
int t=1;
cin>>t;
while(t--){
solve();
}
//system("pause");
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Time Limit Exceeded
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 ...