QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#45426 | #4398. Luxury cruise ship | miaomiaozi | AC ✓ | 2ms | 4396kb | C++17 | 1.3kb | 2022-08-23 18:37:35 | 2022-08-23 18:37:37 |
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 / N;
n %= N;
ans += x * f[N];
cout << (f[n] == inf ? -1 : f[n] + ans) << 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;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 4396kb
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:
ok 1000 lines