fork(2) download
  1. z = input()
  2. tablica_wynikow = []
  3. for i in range(0,int(z)):
  4. k = 0.0
  5. reszta = 0
  6. #x = "13 -5".split()
  7. x = input().split()
  8. x = [int(j) for j in x]
  9. for r in range(0,abs(x[1])):
  10. k = (x[0] - r)/x[1]
  11. if k.is_integer() == True:
  12. reszta = r
  13. r = abs(x[1]) # konczy petle for
  14.  
  15. tablica_wynikow.append(reszta)
  16.  
  17. for y in tablica_wynikow:
  18. print(y)
Success #stdin #stdout 0.03s 9412KB
stdin
4
13 5
-13 5
13 -5
-13 -5
stdout
3
2
3
2