Task: | Pallo |
Sender: | hltk |
Submission time: | 2022-01-22 15:58:41 +0200 |
Language: | C++ (C++17) |
Status: | READY |
Result: | 45 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 10 |
#2 | ACCEPTED | 35 |
#3 | RUNTIME ERROR | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.01 s | 1, 2, 3 | details |
#2 | ACCEPTED | 0.01 s | 2, 3 | details |
#3 | RUNTIME ERROR | 0.92 s | 3 | details |
Code
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int tt; cin >> tt; while (tt--) { long n, m, k; cin >> n >> m >> k; if (n > m) swap(n, m); vector<long> v; long K = (m - n) / (n - 1); long rem = (m - n) % (n - 1); long x = __gcd(m - n, n - 1); long T = (n - 1) / x; long vs = K + 1 + (T - 1) + ((m - n) % (n - 1) + (m - n) * (T - 1)) / (n - 1); long ans = k / (vs * (n - 1)) * (vs + (T - 1)); k %= vs * (n - 1); if (k <= (K + 1) * (n - 1)) { ans += k / (n - 1); k = 0; } else { k -= (K + 1) * (n - 1); ans += K + 1; } for (long t0 = 0; t0 < T - 1; ++t0) { v.push_back(rem); v.push_back(n - 1 - rem); rem += m - n; for (int t = 0; t < rem / (n - 1); ++t) { v.push_back(n - 1); } rem %= n - 1; } long s = 0; int it = 0; while (v.size() && k >= v[it]) { s++; k -= v[it]; it++; if (it == (int) v.size()) { it = 0; } } cout << ans + s << endl; } }
Test details
Test 1
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
100 10 5 76 9 8 78 8 6 49 3 3 94 ... |
correct output |
---|
25 19 15 47 8 ... |
user output |
---|
25 19 15 47 8 ... Truncated |
Test 2
Group: 2, 3
Verdict: ACCEPTED
input |
---|
1000 7 5 99033171167123849 6 8 472883555390027162 9 10 258937093512465880 10 6 691774305483997493 ... |
correct output |
---|
33011057055707949 148620545979722822 57541576336103529 199845910473154830 52151060432923288 ... |
user output |
---|
33011057055707949 148620545979722822 57541576336103529 199845910473154830 5215106043292328 ... Truncated |
Test 3
Group: 3
Verdict: RUNTIME ERROR
input |
---|
1000 816332614 86098803 33572721929... |
correct output |
---|
4310587870 45982113074 1550250683 717639357 3282221941 ... |
user output |
---|
(empty) |