nq1s788

13 кол-во ip-адресов где 1 нечетно

Apr 5th, 2025 (edited)
1,643
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.40 KB | None | 0 0
  1. #13 https://kompege.ru/variant?kim=25088424
  2. def to_bin(x):
  3.     s = bin(x)[2:]
  4.     return '0' * (8 - len(s)) + s
  5.  
  6.  
  7. setb = to_bin(172) + '.' + to_bin(16) + '.' + to_bin(80) + '.' + to_bin(0)
  8. maska = to_bin(255) + '.' + to_bin(255) + '.' + to_bin(248) + '.' + to_bin(0)
  9. print(setb)
  10. print(maska)
  11. cnt = 0
  12. for x in range(2**11):
  13.     s = bin(x)[2:]
  14.     if s.count('1') % 2 != 0:
  15.         cnt += 1
  16. print(cnt)
Advertisement
Add Comment
Please, Sign In to add comment