Promi_38

cf 990A

Jan 12th, 2021
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.22 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. int main()
  4. {
  5.     long long n, m;
  6.     int a, b;
  7.     scanf("%lld %lld %d %d", &n, &m, &a, &b);
  8.    
  9.     if(a * (m - (n % m)) > b * (n % m)) printf("%lld\n", b * (n % m));
  10.     else printf("%lld\n", a * (m - (n % m)));
  11. }
Advertisement
Add Comment
Please, Sign In to add comment