File size: 2,893 Bytes
9cd84db
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
'''
#1
 
#1111.1111_2 + 23.32_4
print(15.9375 + 11.875)
#27.8125 -> 1B.D
 
#4
 
mx = []
for n in range(1, 1000):
     z = n
     s = ''
     while z > 0:
          s = str(z % 2) + s
          z //= 2
     if n % 2 == 0:
          s += str(z.count('1') % 2)
          print(s)
          s = (str(bin(sum((list(map(int, str(n).split())))))))[2:] + s
     else:
          s += '0'
          s += (str(bin(sum((list(map(int, str(n).split())))))))[2:]
     
     r = int(s, 2)
     if r >= 200:
          break
     else:
          print(n, r)
 
#5
 
def binaryOfFraction(fraction):

    binary = str()
    while (fraction):
        fraction *= 2
        if (fraction >= 1):
            int_part = 1
            fraction -= 1
        else:
            int_part = 0
        binary += str(int_part)
 
    return binary
 
 
def floatingPoint(real_no):
    sign_bit = 0
    if(real_no < 0):
        sign_bit = 1
    real_no = abs(real_no)
    int_str = bin(int(real_no))[2 : ]
    fraction_str = binaryOfFraction(real_no - int(real_no))
    ind = int_str.index('1')
    exp_str = bin((len(int_str) - ind - 1) + 127)[2 : ]
    mant_str = int_str[ind + 1 : ] + fraction_str
    mant_str = mant_str + ('0' * (23 - len(mant_str)))
    return sign_bit, exp_str, mant_str
 
 
 
sign_bit, exp_str, mant_str = floatingPoint(14.59375)

ieee_32 = str(sign_bit) + exp_str + mant_str
print(ieee_32)
ieee_32 = int(ieee_32, 2)
ieee_32 = hex(ieee_32)
print(ieee_32)
   
#6
 
x = 640
y = 192
m = 150 * 1024 * 8
proz = 2
color = (m/(x * y)) - proz
print(2 ** color)
 
#7
 
workers = 3000 - 150 
for a in range(10000):
    if 800 + 730 + 900 - 90 - 70 - 120 + 2*a == workers:
        print(a)
#a = 140
 
#8
p = 157
q = 733
e = 17
def f(p, q):
    return (p - 1) * (q - 1)
for d in range(10 ** 5):
    if (d*e) % f(p, q) == 1:
        print(d)
 
 
#10
 
print((59 << 1) & (~14 | (133 >> 2)))
 
#11
 
def fn(x, y):
    if x == y:
        return 1 
    if x < y:
        return fn(x+2, y) + fn(x+3, y) + fn(x+5, y)
    else:
        return 0
print(fn(20, 35)) #если проходит через какое-то число, разделить на две функции
 
#12
 
count = 0
for s in range(2, 10000, 2):
    n = 120
    while s > 0:
        s = s // 6
        n = n - 6
    if n == 108:
        count += 1
print(count)
 
#13
 
f = open('11.txt')
s = [int(x) for x in f]
count = 0
sums = []
for i in range(1, len(s) - 1):
    if s[i] % 8 == 0 and s[i + 1] % 8 == 0:
        count += 1
        sums.append(s[i] + s[i + 1])
print(count)
print(min(sums))'''