fork download
  1. import math
  2. for _ in range(int(input())):
  3. a, b = map(int, input().split())
  4. x = max(a,b)
  5. b = min(a,b)
  6. li = [1, 2, 5]
  7. y = 0
  8. if x == b:
  9. print(0)
  10. elif x in li:
  11. print(1)
  12. else:
  13. if x-b > 5:
  14. y = math.floor((x-b)/5)
  15. if y*5 != x:
  16. z = (x-a)%5
  17. if z == 4 or z == 3:
  18. print(y+2)
  19. else:
  20. print(y+1)
  21. elif x-b>2:
  22. print(2)
  23. else:
  24. print(1)
Success #stdin #stdout 0.02s 9184KB
stdin
8
0 4
4 0
3 2
2 3
2 10
5 5
0 1
0 6
stdout
2
2
1
1
3
0
1
2