QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#485329 | #9107. Zayin and Count | propane# | RE | 0ms | 0kb | C++20 | 1.6kb | 2024-07-20 16:29:54 | 2024-07-20 16:29:54 |
answer
#include<iostream>
#include<cstring>
#include<vector>
#include<climits>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
int a[70], len;
ULL f[11][70];
bool v[11][70];
ULL dfs(int state, int u, bool lim){
if (u == 0) return 1;
if (!lim and v[state][u]){
return f[state][u];
}
v[state][u] = true;
ULL 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));
}
}
return f[state][u] = ans;
}
ULL get(int state, ULL 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 x;
cin >> x;
LL cnt = get(state1, x);
ULL l = 0, r = ULLONG_MAX;
while(l < r){
ULL mid = (__uint128_t(l) + r) / 2;
if (get(state2, mid) >= cnt) r = mid;
else l = mid + 1;
}
cout << r << '\n';
}
}
詳細信息
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 ...