QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#575410 | #9107. Zayin and Count | leafmaple# | WA | 25ms | 3588kb | C++20 | 3.0kb | 2024-09-19 13:55:29 | 2024-09-19 13:55:29 |
Judging History
answer
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
using ll = long long;
const int N=1e6+5;
__int128 cal(vector<int> vec, string s){
int cnt = 0;
int tot = 0;
map<int,int>mp;
if(vec[0] == 1){
for(int i=0; i<10; i++) if(vec[i]) {
cnt++;
mp[i] = tot++;
}
for(auto &c: s){
int x = c-'0';
c = mp[x] + '0';
}
__int128 ans = 0;
for(int i=0; i<s.size(); i++){
ans = ans * cnt + s[i]-'0';
}
return ans+1;
}else {
for(int i=0; i<10; i++) if(vec[i]) {
cnt++;
mp[i] = ++tot;
}
for(auto &c: s){
int x = c-'0';
c = mp[x] + '0';
}
__int128 ans = 0;
for(int i=0; i<s.size(); i++){
ans = ans * cnt + s[i]-'0';
}
return ans;
}
}
void fk(vector<int>vec, __int128 k){
map<int,int>mp;
__int128 cnt = 0, tot = 0;
if(vec[0] == 1){
k-=1;
for(int i=0; i<10; i++) if(vec[i]) {
cnt++;
mp[tot++] = i;
}
string ans;
while(k){
ans += k%cnt + '0';
k /= cnt;
}
for(auto &c: ans){
c = mp[c-'0'] + '0';
}
reverse(ans.begin(), ans.end());
cout << ans << endl;
return ;
}
for(int i=0; i<10; i++) if(vec[i]) {
cnt++;
mp[++tot] = i;
}
vector<__int128>pk(200); pk[0] = 1;
for(int i=1; i<=64; i++) pk[i] = pk[i-1]*cnt;
__int128 sum = 0;
for(int i=0; i<=64;i++)
{
sum += pk[i]*cnt;
if(sum >= k)
{
sum -= pk[i]*cnt;
k -= sum ;
sum = 0;
for(int j=i;j>=0;j--)
{
for(int l = 1;l<=cnt ;l++)
{
if(pk[j]*l >= k)
{
cout<<mp[l];
//cout<<pk[j]*(l - 1)<<endl;
k -=pk[j]*(l - 1);
break;
}
}
sum = 0 ;
if(j == 0)
break;
}
return ;
}
}
// for(int i=64; i>=0; i--){
// // for(int j=1; j<=cnt; j++){
// // j*cnt^(i-1) >= k -> base[i] = j
// // }
// }
}
void solve(){
vector<int>a(15), b(15);
for(int i=0; i<10; i++) cin >> a[i];
for(int i=0; i<10; i++) cin >> b[i];
string x; cin >> x;
__int128 k = cal(a, x);
// cout << k << endl;
fk(b, k);
}
signed main(){
cin.tie(0)->sync_with_stdio(0);
int T; T=1;
cin >> T;
while(T--) solve();
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 25ms
memory: 3588kb
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:
5275524456726276674257572241990991999414091249949 101364364636933104003903 57558888789255872922852552757222758857875785288225787822761161760076076167101117776167 5666658655566868656665658685656668665815611661611611111511116116661611616155505885888775005550558080707878 3912911219633669993999199888568...
result:
wrong answer 1st lines differ - expected: '52755244567262766742575722', found: '5275524456726276674257572241990991999414091249949'