1
This commit is contained in:
21
levieProekti/Olymp2020/uoi/2 tour/C-Triyka.py
Normal file
21
levieProekti/Olymp2020/uoi/2 tour/C-Triyka.py
Normal file
@@ -0,0 +1,21 @@
|
||||
chisloVV = int(input())
|
||||
deystviy = 0
|
||||
|
||||
while chisloVV != 1:
|
||||
if chisloVV % 3 == 0:
|
||||
chisloVV = chisloVV / 3
|
||||
deystviy += 1
|
||||
|
||||
elif (chisloVV + 1) % 3 == 0:
|
||||
chisloVV = (chisloVV + 1) / 3
|
||||
deystviy += 2
|
||||
|
||||
elif (chisloVV - 1) % 3 == 0:
|
||||
chisloVV = (chisloVV - 1) / 3
|
||||
deystviy += 2
|
||||
|
||||
else:
|
||||
chisloVV = chisloVV - 1
|
||||
deystviy += 1
|
||||
|
||||
print(deystviy)
|
||||
Reference in New Issue
Block a user