QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#45425 | #4398. Luxury cruise ship | miaomiaozi | WA | 4ms | 4360kb | C++17 | 1.5kb | 2022-08-23 18:33:34 | 2022-08-23 18:33:35 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
// https://space.bilibili.com/672346917
#ifndef LOCAL
#define LOG(...) 42
#endif
#define fi first
#define se second
#define pb push_back
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long LL;
typedef pair <int, int> PII;
constexpr double EPS = 1e-8;
const double PI = acos(-1);
int multi_cases = 1;
constexpr int N = 7 * 31 * 365 * 2;
constexpr LL inf = 1e18;
int do_init = 0;
vector <LL> f(N + 5, inf);
void A_SOUL_AvA () {
if (!do_init) {
do_init = 1;
f[7] = f[31] = f[365] = 1;
vector <int> a = {7, 31, 365};
for (int v : a) {
for (int j = v; j <= N; j++) {
f[j] = min(f[j], f[j - v] + 1);
}
}
}
LL n;
cin >> n;
LL k = N / 361;
LL ans = 0;
if (n <= N) {
cout << (f[n] == inf ? -1 : f[n]) << endl;
} else {
LL x = (n + 360) / 361;
assert(x >= k);
ans += x - k;
n -= (x - k) * 361;
assert(n <= N);
if (f[n] == inf) {
cout << -1 << endl;
} else {
cout << ans + f[n] << endl;
}
}
}
int main () {
cin.tie(nullptr)->sync_with_stdio(false);
cout << fixed << setprecision(12);
int T = 1;
for (multi_cases && cin >> T; T; T--) {
A_SOUL_AvA ();
}
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 4ms
memory: 4360kb
input:
1000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101...
output:
-1 -1 -1 -1 -1 -1 1 -1 -1 -1 -1 -1 -1 2 -1 -1 -1 -1 -1 -1 3 -1 -1 -1 -1 -1 -1 4 -1 -1 1 -1 -1 -1 5 -1 -1 2 -1 -1 -1 6 -1 -1 3 -1 -1 -1 7 -1 -1 4 -1 -1 -1 8 -1 -1 5 -1 -1 2 9 -1 -1 6 -1 -1 3 10 -1 -1 7 -1 -1 4 11 -1 -1 8 -1 -1 5 12 -1 -1 9 -1 -1 6 13 -1 3 10 -1 -1 7 14 -1 4 11 -1 -1 8 15 -1 5 12 -1 -...
result:
wrong answer 401st lines differ - expected: '1431', found: '1455'