QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#547408 | #9107. Zayin and Count | wzxtsl# | RE | 0ms | 0kb | C++17 | 1.6kb | 2024-09-04 21:27:07 | 2024-09-04 21:27: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=2e5+7;
int n,m,ca,cb;
int a[N],b[N],op;
int x,len;
int s[N];
int p[15][31];
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 ...