← Back to List

31613번: 繰り返し (Repetition) ↗

Solutions

Python 3
691 B | 691 chars
import sys
from math import sqrt, pi, sin, factorial, ceil, floor
from datetime import datetime, timedelta
# sys.setrecursionlimit(10**7)

BLANK = " "

# inp = input
inp = lambda : sys.stdin.readline().rstrip()
mii = lambda x = BLANK : [*map(int,inp().split(x))]
mfi = lambda x = BLANK : [*map(float,inp().split(x))]
ii = lambda : int(inp())
fi = lambda : float(inp())
p = print

def solve():
    x = ii()
    n = ii()

    cnt = 0

    while x < n:
        cnt += 1
        r = x % 3

        if r == 0:
            x += 1
        elif r == 1:
            x *= 2
        else:
            x *= 3

    p(cnt)

if __name__ == "__main__":
  tc = 1

  for t in range(1, tc+1):
    ret = solve()