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