Advertisement
Misha_

Твоя прога <3

Nov 22nd, 2018
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.39 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. int min(int a, int b) {
  6.     return (a <= b ? a : b);
  7. }
  8.  
  9. int main() {
  10.     short n, m, a, b;
  11.     int res = 0;
  12.     cin >> n >> m >> a >> b;
  13.     if (a <= ceil(b / m))
  14.         res = n * a;
  15.     else {
  16.         res = (n / m) * b;
  17.         if (n % m != 0)
  18.             res += min(n % m * a, b);
  19.     }
  20.     cout << res;
  21.     return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement