QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#485348 | #9107. Zayin and Count | propane# | WA | 385ms | 3728kb | C++20 | 1.7kb | 2024-07-20 16:42:34 | 2024-07-20 16:42:34 |
Judging History
answer
#include<iostream>
#include<cstring>
#include<vector>
#include<climits>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using i128 = __int128_t;
int a[70], len;
i128 f[1 << 10][70];
bool v[1 << 10][70];
i128 dfs(int state, int u, bool lim){
if (u == 0) return 1;
if (!lim and v[state][u]){
return f[state][u];
}
if (state == 3 and u == 3 and lim == false){
int t = 0;
}
if (!lim) v[state][u] = true;
i128 ans = 0;
int up = lim ? a[u] : 9;
for(int i = 0; i <= up; i++){
if (state >> i & 1){
ans += dfs(state, u - 1, lim and (i == up));
}
}
if (!lim) f[state][u] = ans;
return ans;
}
i128 get(int state, i128 x){
int len = 0;
while(x){
a[++len] = x % 10;
x /= 10;
}
return dfs(state, len, true);
}
int main(){
#ifdef LOCAL
freopen("data.in", "r", stdin);
freopen("data.out", "w", stdout);
#endif
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(0);
memset(v, 0, sizeof v);
int T;
cin >> T;
while(T--){
int state1 = 0, state2 = 0;
for(int i = 0; i < 10; i++){
int x;
cin >> x;
state1 |= x << i;
}
for(int i = 0; i < 10; i++){
int x;
cin >> x;
state2 |= x << i;
}
ULL xx;
cin >> xx;
i128 x = xx;
i128 cnt = get(state1, x);
i128 l = 0, r = ULLONG_MAX;
while(l < r){
i128 mid = (l + r) / 2;
if (get(state2, mid) >= cnt) r = mid;
else l = mid + 1;
}
cout << (ULL)r << '\n';
}
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 385ms
memory: 3728kb
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:
2247222755554242566 5380300354831952555 5380300354831952555 5380300354831952555 5380300354831952555 5380300354831952555 5380300354831952555 5380300354831952555 5380300354831952555 5380300354831952555 5380300354831952555 5380300354831952555 5380300354831952555 5380300354831952555 5380300354831952555 ...
result:
wrong answer 1st lines differ - expected: '52755244567262766742575722', found: '2247222755554242566'