diff options
Diffstat (limited to '18_additional_problems_ii/bouncing_ball_steps_3215.cpp')
| -rw-r--r-- | 18_additional_problems_ii/bouncing_ball_steps_3215.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/18_additional_problems_ii/bouncing_ball_steps_3215.cpp b/18_additional_problems_ii/bouncing_ball_steps_3215.cpp new file mode 100644 index 0000000..b09bba2 --- /dev/null +++ b/18_additional_problems_ii/bouncing_ball_steps_3215.cpp | |||
| @@ -0,0 +1,24 @@ | |||
| 1 | #include <algorithm> | ||
| 2 | #include <iostream> | ||
| 3 | #include <numeric> | ||
| 4 | #include <tuple> | ||
| 5 | |||
| 6 | typedef long long ll; | ||
| 7 | |||
| 8 | std::tuple<ll, ll, ll> f(ll n, ll m, ll k) { | ||
| 9 | n--; m--; | ||
| 10 | ll am{k % (2*n)}, ad{k / n}, bm{k % (2*m)}, bd{k / m}; | ||
| 11 | if (am > n) am = n - (am-n); | ||
| 12 | if (bm > m) bm = m - (bm-m); | ||
| 13 | return {am, bm, ad+bd-k/std::lcm(n, m)}; | ||
| 14 | } | ||
| 15 | |||
| 16 | int main() { | ||
| 17 | ll t, n, m, k; | ||
| 18 | std::cin >> t; | ||
| 19 | for (ll i = 0; i < t; i++) { | ||
| 20 | std::cin >> n >> m >> k; | ||
| 21 | auto [a, b, c] = f(n, m, k); | ||
| 22 | std::cout << a+1 << " " << b+1 << " " << c << "\n"; | ||
| 23 | } | ||
| 24 | } | ||
