QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#504747 | #9107. Zayin and Count | Folity# | WA | 7ms | 3868kb | C++20 | 1.4kb | 2024-08-04 15:33:23 | 2024-08-04 15:33:24 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef __uint128_t ulll;
bool a[10],b[10];
int s[10],nb[10],ma,mb;
ull X,Y;
vector<int> digit(ull X){
vector<int> res;
while(X)res.push_back(X%10),X/=10;
return res;
}
ull pw(ull x,int y){
ull r=1;
for(;y;y>>=1){
if(y&1)r=r*x;
x=x*x;
}
return r;
}
void solve(){
ma=mb=0;
for(int i=0;i<10;++i){
cin>>a[i];
ma+=a[i],s[i]=(i?s[i-1]:0)+a[i];
}
for(int i=0;i<10;++i){
cin>>b[i];
if(b[i])nb[mb++]=i;
}
cin>>X;
vector<int> dig=digit(X);
ull num=0;
for(int k=1;k<dig.size();++k){
num+=(ma-(a[0]&&k>1))*pw(ma,k-1);
}
for(int k=dig.size()-1;k>=0;--k){
num+=(s[dig[k]]-1-(a[0]&&k==dig.size()-1))*pw(ma,k);
}
//cout<<num<<'\n';
int k=0;
ulll sum=0;
while(sum<=num){
++k;
sum+=(mb-(b[0]&&k>1))*pw(mb,k-1);
}
sum-=(mb-(b[0]&&k>1))*pw(mb,k-1);
vector<int> ans;
for(int i=k-1;i>=0;--i){
for(int j=b[0]&&i==k-1;j<mb;++j){
sum+=pw(ma,k);
if(sum>num){
ans.push_back(nb[j]);
break;
}
}
sum-=pw(ma,k);
}
for(int x:ans)cout<<x;
cout<<'\n';
}
int main(){
ios::sync_with_stdio(0);cin.tie(0);
int T;
cin>>T;
while(T--)solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 7ms
memory: 3868kb
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:
7222222222 7222222222 7222222222 7222222222 7222222222 7222222222 7222222222 7222222222 7222222222 7222222222 7222222222 7222222222 7222222222 7222222222 7222222222 7222222222 7222222222 7222222222 7222222222 7222222222 7222222222 7222222222 7222222222 7222222222 7222222222 7222222222 7222222222 722...
result:
wrong answer 1st lines differ - expected: '52755244567262766742575722', found: '7222222222'