Saleh127

codeforces 466A.cpp

Jun 6th, 2020
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define test int t; cin>>t; while (t--)
  4. #define ll long long int
  5. #define Faster ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  6. #define pi acos(-1)
  7. #define yes printf("YES\n");
  8. #define no printf("NO\n");
  9. int main()
  10. {
  11. Faster
  12.  
  13. int n,m,a,c,d,e,f,i,g,x,y;
  14. cin>>n>>m>>a>>c;
  15. if(m>=n)
  16. {
  17. cout<<min(n*a,c)<<endl;
  18. return 0;
  19. }
  20. i=n/m;
  21. d=n*a;
  22. e=(m*c)+(n-m)*a;
  23. g=i*c+(n%m)*a;
  24. y=(n/m+1)*c;
  25. x=min(d,min(g,min(e,y)));
  26. cout<<x<<endl;
  27. return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment