Advertisement
dmemsm

Задача 5

Jan 12th, 2025
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.80 KB | None | 0 0
  1. ar_count = 2
  2. ge_count = 2
  3. max_ar_count = 2
  4. max_ge_count = 2
  5.  
  6. prev_elem = int(input())
  7. inp = int(input())
  8. d = inp - prev_elem
  9. q = inp / prev_elem
  10. while True:
  11.     prev_elem = inp
  12.     inp = int(input())
  13.     if inp == 0:
  14.         if ar_count > max_ar_count:
  15.             max_ar_count = ar_count
  16.         if ge_count > max_ge_count:
  17.             max_ge_count = ge_count
  18.         break
  19.  
  20.     if inp - prev_elem == d:
  21.         ar_count += 1
  22.     else:
  23.         if ar_count > max_ar_count:
  24.             max_ar_count = ar_count
  25.         ar_count = 2
  26.         d = inp - prev_elem
  27.  
  28.     if inp / prev_elem == q:
  29.         ge_count += 1
  30.     else:
  31.         if ge_count > max_ge_count:
  32.             max_ge_count = ge_count
  33.         ge_count = 2
  34.         q = inp / prev_elem
  35.  
  36. print(max(max_ar_count, max_ge_count))
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement