fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. long long a, b;
  6. cin >> a >> b;
  7.  
  8. long long r = a - a / b * b;
  9.  
  10. if (a >= 0 && b >= 0) {
  11. cout << ;
  12. } else {
  13. cout << min(r, abs(r - (a / b + 1)* b))
  14. }
  15.  
  16.  
  17. return 0;
  18. }
Success #stdin #stdout 0.01s 5288KB
stdin
27 4
stdout
7