fork(1) download
  1. #include <iostream>
  2. #include <math.h>
  3. using namespace std;
  4. long long int a,b,d,r;
  5. int main()
  6. {
  7. cin >> d;
  8. for (int i=1;i<=d;i++)
  9. {
  10. cin >> a >> b;
  11. b=fabs(b);
  12. r=a%b;
  13. cout << r << endl;
  14. }
  15. return 0;
  16. }
Success #stdin #stdout 0s 15232KB
stdin
4
5 2
12 5
5 8
15 5
stdout
1
2
5
0