Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // OK A region second tour 16/17 https://informatics.mccme.ru/mod/statements/view.php?id=24703#1
- #include <iostream>
- using namespace std;
- int main()
- {
- int64_t k, x, y;
- cin >> k;
- cin >> x;
- cin >> y;
- if (y <= x) {
- cout << x;
- }
- else {
- int64_t n = y / x;
- if (y / x != 0) {
- n++;
- }
- if ((n - 1) * (k - 1) >= (y - x * (n - 1))) {
- cout << y;
- }
- else {
- cout << n * x;
- }
- }
- }
Add Comment
Please, Sign In to add comment