Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int min(int a, int b) {
- return (a <= b ? a : b);
- }
- int main() {
- short n, m, a, b;
- int res = 0;
- cin >> n >> m >> a >> b;
- if (a <= ceil(b / m))
- res = n * a;
- else {
- res = (n / m) * b;
- if (n % m != 0)
- res += min(n % m * a, b);
- }
- cout << res;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement