nq1s788

13 кол-во айпи адресов с третим битом нужным

Dec 3rd, 2025
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.40 KB | None | 0 0
  1. #https://inf-ege.sdamgia.ru/problem?id=76116
  2. def binn(x):
  3.     return '0' * (8 - len(bin(x)[2:])) + bin(x)[2:]
  4.  
  5.  
  6. print(binn(205), binn(182), binn(128), binn(0), sep='.')
  7. print(binn(255), binn(255), binn(192), binn(0), sep='.')
  8. answ = 0
  9. for x in range(2**14):
  10.     ip = '110011011011011010' + '0' * (14 - len(bin(x)[2:])) + bin(x)[2:]
  11.     if ip[16:24].count('1') == 4:
  12.         answ += 1
  13. print(answ)
Advertisement
Add Comment
Please, Sign In to add comment