QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#328475 | #7881. Computational Complexity | wcyQwQ | WA | 263ms | 22708kb | C++14 | 2.4kb | 2024-02-15 20:20:08 | 2024-02-15 20:20:09 |
Judging History
answer
#include <bits/stdc++.h>
#define L(i, j, k) for (int i = (j); i <= (k); i++)
#define R(i, j, k) for (int i = (j); i >= (k); i--)
using namespace std;
using LL = long long;
const int N = 15, M = 1e6 + 10;
const LL V = 1e15;
LL f[N], g[N], mod;
int T;
map<LL, LL> dF, dG;
map<LL, int> cc;
template<class T = int> T read() {
T x = 0, y = 1;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-') {
y = -1;
}
c = getchar();
}
while (c >= '0' && c <= '9') {
x = x * 10 + c - '0';
c = getchar();
}
return x * y;
}
void push(LL cur, vector<LL> &v) {
if (cc[cur]) {
return;
}
cc[cur] = 1;
if (cur >= 14) {
v.emplace_back(cur);
}
for (int p : {2, 3, 5, 7}) {
if (cur <= V / p) {
push(cur * p, v);
}
}
}
LL getF(LL p) {
return dF.find(p) == dF.end() ? 0 : dF[p];
}
LL getG(LL p) {
return dG.find(p) == dG.end() ? 0 : dG[p];
}
int main() {
f[0] = read(), g[0] = read(), T = read();
mod = read<LL>();
L(i, 1, 13) {
f[i] = max((LL)i, g[i / 2] + g[i / 3] + g[i / 5] + g[i / 7]);
g[i] = max((LL)i, f[i / 2] + f[i / 3] + f[i / 4] + f[i / 5]);
dF[i] = (f[i] - f[i - 1]) % mod;
dG[i] = (g[i] - g[i - 1]) % mod;
}
vector<LL> vec;
push(1, vec);
push(11, vec);
push(13, vec);
sort(vec.begin(), vec.end());
for (int p : vec) {
dF[p] = (LL)(!(p % 2) * getG(p / 2) + !(p % 3) * getG(p / 3) + !(p % 5) * getG(p / 5) + !(p % 7) * getG(p / 7)) % mod;
dG[p] = (LL)(!(p % 2) * getF(p / 2) + !(p % 3) * getF(p / 3) + !(p % 4) * getF(p / 4) + !(p % 5) * getF(p / 5)) % mod;
}
int cnt = 0;
vector<pair<LL, LL>> F, G;
F.push_back({0, f[0]});
G.push_back({0, g[0]});
for (auto t : dF) {
F.push_back(t);
}
for (auto t : dG) {
G.push_back(t);
}
assert(F.size() == G.size());
L(i, 1, (int)F.size() - 1) {
(F[i].second += F[i - 1].second) %= mod;
(G[i].second += G[i - 1].second) %= mod;
}
while (T--) {
LL m = read<LL>();
printf("%lld %lld\n", (*--upper_bound(F.begin(), F.end(), make_pair(m, V))).second, (*--upper_bound(G.begin(), G.end(), make_pair(m, V))).second);
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 262ms
memory: 22672kb
input:
1958 920 10 100000000000 0 1 2 3 10 100 200 1000 19580920 20232023
output:
1958 920 3680 7832 10592 9554 17504 11276 50294 64826 784112 893714 1894550 1905470 12057866 12979424 71481494756 48626708512 28127864908 7251681354
result:
ok 20 numbers
Test #2:
score: 0
Accepted
time: 263ms
memory: 22700kb
input:
0 0 10 100000000000 0 1 2 3 4 10 20 30 40 100
output:
0 0 1 1 2 2 3 3 4 4 11 12 25 26 41 41 55 58 162 172
result:
ok 20 numbers
Test #3:
score: 0
Accepted
time: 254ms
memory: 22684kb
input:
2023 2023 10 2023 0 1 2 3 4 5 6 7 8 9
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
result:
ok 20 numbers
Test #4:
score: -100
Wrong Answer
time: 240ms
memory: 22708kb
input:
36092 30559 2149 729566623185 909730017626 961811467628 978809456383 494310140318 760462959632 726343527430 220697276132 366336227300 456813204361 569783542145 13854148170 51526515764 564416233246 876430686824 862897449267 956440673661 512777546436 728860125927 799238602356 978766770799 47962348351 ...
output:
437224680581 618114897662 437224680581 618114897662 437224680581 618114897662 437224680581 618114897662 437224680581 618114897662 437224680581 618114897662 437224680581 618114897662 437224680581 618114897662 437224680581 618114897662 437224680581 618114897662 437224680581 618114897662 437224680581 6...
result:
wrong answer 1st numbers differ - expected: '192287632545', found: '437224680581'