QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#569814 | #9107. Zayin and Count | SGColin# | WA | 21ms | 3876kb | C++17 | 1.2kb | 2024-09-17 11:05:40 | 2024-09-17 11:05:40 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
inline ll rd() {
ll x = 0;
bool f = 0;
char c = getchar();
for (; !isdigit(c); c = getchar()) f |= (c == '-');
for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
return f ? -x : x;
}
#define eb emplace_back
#define all(s) (s).begin(), (s).end()
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)
const int N = 100007;
char s[N];
ull fpow(ull x, int t) {
ull res = 1;
for (; t; t >>= 1, x = x * x)
if (t & 1) res = res * x;
return res;
}
void work() {
vector<int> A, B;
rep(i, 0, 9) {int w = rd(); if (w) A.eb(i);}
rep(i, 0, 9) {int w = rd(); if (w) B.eb(i);}
scanf("%s", s + 1);
int n = strlen(s + 1);
auto getv = [&](vector<int> &s, int w) {
return lower_bound(all(s), w) - s.begin() + 1;
};
ull tot = 0;
rep(i, 1, n) {
int w = getv(A, s[i] - '0');
tot += (w - 1) * fpow(A.size(), n - i);
}
vector<int> ans;
if (tot == 0) ans.eb(B[0]);
while (tot) {
ans.eb(B[tot % B.size()]);
tot /= B.size();
}
reverse(all(ans));
for (auto x : ans) printf("%d", x); puts("");
}
int main() {
per(t, rd(), 1) work();
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 21ms
memory: 3876kb
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:
65266455722475422254727242 41990991999414091249949 101364364636933104003903 57259252998225997772927975 878555885282288227752558252252 610010606760761011770006661017 68888858668556558688868865568855558868 51566165566155616511615666156611165656 505885888775005550558080707878 3333916221911699323366319 ...
result:
wrong answer 1st lines differ - expected: '52755244567262766742575722', found: '65266455722475422254727242'