fork(2) 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. n = input().split()
  11. if n != '':
  12. x = int(n[0])
  13. y = int(n[1])
  14. r = int(n[2])
  15. tab.append(x)
  16. tab.append(y)
  17. tab.append(r)
  18. k += 1
  19.  
  20. length = sqrt((tab[3]-tab[0])**2\
  21. +(tab[4]-tab[1])**2)
  22.  
  23. next_len = (tab[2]*2+tab[5]*2) - (length + tab[2]+tab[5])
  24. if next_len < 0:
  25. next_len = 0
  26. elif length == 0:
  27. if tab[2] > tab[5]:
  28. next_len = 2 * tab[5]
  29. else:
  30. next_len = 2 * tab[2]
  31.  
  32. tav.append(next_len)
  33.  
  34. end += 1
  35. print()
  36. for i in tav:
  37. 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