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
|
| 11 |
+
for n in range(1, 1000):
|
| 12 |
+
z = n
|
| 13 |
+
s = ''
|
| 14 |
+
while z > 0:
|
| 15 |
+
s = str(z % 2) + s
|
| 16 |
+
z //= 2
|
| 17 |
+
if n % 2 == 0:
|
| 18 |
+
s += str(z.count('1') % 2)
|
| 19 |
+
print(s)
|
| 20 |
+
s = (str(bin(sum((list(map(int, str(n).split())))))))[2:] + s
|
| 21 |
+
else:
|
| 22 |
+
s += '0'
|
| 23 |
+
s += (str(bin(sum((list(map(int, str(n).split())))))))[2:]
|
| 24 |
+
|
| 25 |
+
r = int(s, 2)
|
| 26 |
+
if r >= 200:
|
| 27 |
+
break
|
| 28 |
+
else:
|
| 29 |
+
print(n, r)
|
| 30 |
+
|
| 31 |
+
#5
|
| 32 |
+
|
| 33 |
+
def binaryOfFraction(fraction):
|
| 34 |
+
|
| 35 |
+
binary = str()
|
| 36 |
+
while (fraction):
|
| 37 |
+
fraction *= 2
|
| 38 |
+
if (fraction >= 1):
|
| 39 |
+
int_part = 1
|
| 40 |
+
fraction -= 1
|
| 41 |
+
else:
|
| 42 |
+
int_part = 0
|
| 43 |
+
binary += str(int_part)
|
| 44 |
+
|
| 45 |
+
return binary
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
def floatingPoint(real_no):
|
| 49 |
+
sign_bit = 0
|
| 50 |
+
if(real_no < 0):
|
| 51 |
+
sign_bit = 1
|
| 52 |
+
real_no = abs(real_no)
|
| 53 |
+
int_str = bin(int(real_no))[2 : ]
|
| 54 |
+
fraction_str = binaryOfFraction(real_no - int(real_no))
|
| 55 |
+
ind = int_str.index('1')
|
| 56 |
+
exp_str = bin((len(int_str) - ind - 1) + 127)[2 : ]
|
| 57 |
+
mant_str = int_str[ind + 1 : ] + fraction_str
|
| 58 |
+
mant_str = mant_str + ('0' * (23 - len(mant_str)))
|
| 59 |
+
return sign_bit, exp_str, mant_str
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
sign_bit, exp_str, mant_str = floatingPoint(14.59375)
|
| 64 |
+
|
| 65 |
+
ieee_32 = str(sign_bit) + exp_str + mant_str
|
| 66 |
+
print(ieee_32)
|
| 67 |
+
ieee_32 = int(ieee_32, 2)
|
| 68 |
+
ieee_32 = hex(ieee_32)
|
| 69 |
+
print(ieee_32)
|
| 70 |
+
|
| 71 |
+
#6
|
| 72 |
+
|
| 73 |
+
x = 640
|
| 74 |
+
y = 192
|
| 75 |
+
m = 150 * 1024 * 8
|
| 76 |
+
proz = 2
|
| 77 |
+
color = (m/(x * y)) - proz
|
| 78 |
+
print(2 ** color)
|
| 79 |
+
|
| 80 |
+
#7
|
| 81 |
+
|
| 82 |
+
workers = 3000 - 150
|
| 83 |
+
for a in range(10000):
|
| 84 |
+
if 800 + 730 + 900 - 90 - 70 - 120 + 2*a == workers:
|
| 85 |
+
print(a)
|
| 86 |
+
#a = 140
|
| 87 |
+
|
| 88 |
+
#8
|
| 89 |
+
p = 157
|
| 90 |
+
q = 733
|
| 91 |
+
e = 17
|
| 92 |
+
def f(p, q):
|
| 93 |
+
return (p - 1) * (q - 1)
|
| 94 |
+
for d in range(10 ** 5):
|
| 95 |
+
if (d*e) % f(p, q) == 1:
|
| 96 |
+
print(d)
|
| 97 |
+
|
| 98 |
+
|
| 99 |
+
#10
|
| 100 |
+
|
| 101 |
+
print((59 << 1) & (~14 | (133 >> 2)))
|
| 102 |
+
|
| 103 |
+
#11
|
| 104 |
+
|
| 105 |
+
def fn(x, y):
|
| 106 |
+
if x == y:
|
| 107 |
+
return 1
|
| 108 |
+
if x < y:
|
| 109 |
+
return fn(x+2, y) + fn(x+3, y) + fn(x+5, y)
|
| 110 |
+
else:
|
| 111 |
+
return 0
|
| 112 |
+
print(fn(20, 35)) #если проходит через какое-то число, разделить на две функции
|
| 113 |
+
|
| 114 |
+
#12
|
| 115 |
+
|
| 116 |
+
count = 0
|
| 117 |
+
for s in range(2, 10000, 2):
|
| 118 |
+
n = 120
|
| 119 |
+
while s > 0:
|
| 120 |
+
s = s // 6
|
| 121 |
+
n = n - 6
|
| 122 |
+
if n == 108:
|
| 123 |
+
count += 1
|
| 124 |
+
print(count)
|
| 125 |
+
|
| 126 |
+
#13
|
| 127 |
+
|
| 128 |
+
f = open('11.txt')
|
| 129 |
+
s = [int(x) for x in f]
|
| 130 |
+
count = 0
|
| 131 |
+
sums = []
|
| 132 |
+
for i in range(1, len(s) - 1):
|
| 133 |
+
if s[i] % 8 == 0 and s[i + 1] % 8 == 0:
|
| 134 |
+
count += 1
|
| 135 |
+
sums.append(s[i] + s[i + 1])
|
| 136 |
+
print(count)
|
| 137 |
+
print(min(sums))'''
|