Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # 5й номер https://kpolyakov.spb.ru/school/ege/gen.php?action=viewVar&answers=on&varId=7
- answ = 10000000000
- for x in range(1, 100000):
- cur = x
- s = ''
- while cur != 0:
- s += str(cur % 3)
- cur //= 3
- s = s[::-1]
- if x % 2 == 0:
- s = '2' + s
- if s[-1] == '0':
- s += '0'
- elif s[-1] == '1':
- s += '2'
- else:
- s += '11'
- else:
- s += '2'
- if s[0] == '0':
- s = '0' + s
- elif s[0] == '1':
- s = '2' + s
- else:
- s = '11' + s
- dec = 0
- for i in range(len(s)):
- dec += int(s[i]) * 3 ** (len(s) - i - 1)
- if dec > 100:
- answ = min(answ, dec)
- print(answ)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement