fork download
  1. from math import sqrt
  2.  
  3. t = int(input())
  4. end = 0
  5. tav = []
  6. while t > end:
  7. k = 0
  8. tab = []
  9. while k < 2:
  10. [tab.append(int(x)) for x in input().split() if x != '']
  11. k += 1
  12.  
  13. length = sqrt((tab[3]-tab[0])**2\
  14. +(tab[4]-tab[1])**2)
  15.  
  16. next_len = (tab[2]*2+tab[5]*2) - (length + tab[2]+tab[5])
  17. if next_len < 0:
  18. next_len = 0
  19. elif length == 0:
  20. if tab[2] > tab[5]:
  21. next_len = 2 * tab[5]
  22. else:
  23. next_len = 2 * tab[2]
  24.  
  25. tav.append(next_len)
  26.  
  27. end += 1
  28. print()
  29. for i in tav:
  30. print('{:.2f}'.format(i))
Success #stdin #stdout 0.02s 28384KB
stdin
3
3 3 3
3 -1 4
-3 -3 3
-1 2 5
3 3 2
-3 -3 1
stdout
3.00
2.61
0.00