Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define task "BTICk"
- #include <iostream>
- #include <cstdio>
- using namespace std;
- using ll = long long;
- ll n, k, p1, p2;
- void Read()
- {
- cin >> n >> k >> p1 >> p2;
- }
- void Solve()
- {
- if (p1 >= p2)
- cout << (n + k - 1) / k * p2; // mua ceil(n / k) tệp
- else if (p1 * k <= p2)
- cout << n * p1; // Mua cả n vé lẻ
- else
- {
- ll ans = n / k * p2; // Mua n / k tệp
- ll x = n % k; // Phần dư
- if (p1 * x >= p2)
- ans += p2;
- else
- ans += p1 * x;
- cout << ans;
- }
- }
- int32_t main()
- {
- ios::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- if (fopen(task ".INP", "r"))
- {
- freopen(task ".INP", "r", stdin);
- freopen(task ".OUT", "w", stdout);
- }
- Read();
- Solve();
- }
Add Comment
Please, Sign In to add comment