fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5.  
  6. int a,b;
  7. cin>>a>>b;
  8. int k; cin >> k;
  9.  
  10. // For Addition
  11. cout << (a % k + b % k) % k << endl;
  12.  
  13. // For Substraction
  14. cout << (a % k - b % k + k) % k << endl;
  15.  
  16. // For Multiplication
  17. cout << (a % k * b % k) % k << endl;
  18.  
  19. return 0;
  20. }
Success #stdin #stdout 0.01s 5316KB
stdin
7 8
2
stdout
1
1
0