Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Задание 2:
- print('x y z w')
- for x in 0,1:
- for y in 0,1:
- for z in 0,1:
- for w in 0,1:
- f = (not(y <= (x == w))) and (z <= x)
- if f == 1:
- print(x, y, z, w)
- Задача 4:
- bin(123) - перевод в 2ю систему счисления
- oct(123) - перевод в 8ю систему счисления
- hex(123) - перевод в 16ю систему счисления
- int('10101', 2) - перевод из 2й в 10ю
- int('10101', 5) - перевод из 5й в 10ю
- Задача 6:
- for i in range(1, 10000):
- s = i # int(input())
- s = s // 10
- n = 1
- while s < 51:
- s = s + 5
- n = n * 2
- # print(n)
- if n == 64:
- print(i)
- Задача 8:
- # from math import factorial
- from itertools import permutations, product
- n = 1
- for t in product("ЕЛМРУ", repeat=4):
- st = "".join(t)
- if st[0] == "Л":
- print(n)
- break
- n += 1
- Задача 12:
- s = "8" * 70
- while "2222" in s or "8888" in s:
- if "2222" in s:
- s = s.replace("2222", "88", 1) # заменить 1 раз
- else:
- s = s.replace("8888", "22", 1)
- print(s)
- Задача 14:
- n = 3 * 4**38 + 2 * 4**23 + 4**20 + 3*4**5 + 2 * 4**4 + 1
- p = 16
- k = 0
- while n > 0:
- d = n % p
- if d == 0:
- k += 1
- n = n // p
- print(k)
- Задача 16:
- def F(n):
- if n == 1:
- return 1
- if n % 2 == 0:
- return n + F(n - 1)
- return 2 * F(n - 2)
- print(F(26))
- Задача 17:
- n = 5000
- a = []
- for i in range(n):
- x = int(input())
- a.append(x)
- k = 0
- mx = -20000
- for i in range(1, n):
- if a[i-1] % 3 == 0 or a[i] % 3 == 0:
- k += 1
- if (a[i-1] + a[i]) > mx:
- mx = a[i-1] + a[i]
- print(k, mx)
- Задача 23:
- def F(a, b):
- if a == b:
- return 1
- if a > b:
- return 0
- return F(a+1,b) + F(a*2,b)
- print(F(1,10) * F(10,20))
Advertisement
Add Comment
Please, Sign In to add comment