Advertisement
Pohuyumer

17 стороны остроугольного треугольника

Mar 16th, 2022 (edited)
1,101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.51 KB | None | 0 0
  1. ch = [int(x) for x in open('17.txt')]
  2.  
  3.  
  4. def check(x, y, z):
  5.     if x <= 0 or y <= 0 or z <= 0:
  6.         return 0
  7.     list_of_sides = [x, y, z]
  8.     list_of_sides.sort()
  9.     if (int(list_of_sides[2])) ** 2 < (int(list_of_sides[1])) ** 2 + (int(list_of_sides[0])) ** 2:
  10.         return 1
  11.     else:
  12.         return 0
  13.  
  14.  
  15. count = max_sum = 0
  16. for i in range(2, len(ch)):
  17.     if check(ch[i], ch[i-1], ch[i-2]):
  18.         count += 1
  19.         max_sum = max(max_sum, ch[i] + ch[i-1] + ch[i-2])
  20.  
  21. print(count, max_sum)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement