top of page

소스 코드 제출

공개·회원 52명

20250524

# d = [[0] *50 for i in range(50)]

# def pha(r,c):

# if r < 0 or c < 0:

# return 0

# if r * c == 0:

# d[r][c] = 1

# return 1

# if d[r][c] != 0:

# return d[r][c]

# d[r][c] = pha(r-1,c) + pha(r,c-1)

# return d[r][c]

# r,c = map(int,input().split())

# print(pha(r-1,c-1) % 100000000)


# w = int(input())

# import sys

# sys.setrecursionlimit(100000)

# q =[0] * (w+3)

# def stair(n):

# global x

# if n < 0:

# return 0

# if n == 0:

# return 1

# if q[n] != 0:

# return q[n]

# q[n] = stair(n-1) + stair(n-2) + stair(n-3)

# return q[n]

# stair(w)

# print(q[w] % 1000)


# w = int(input())

# q = [0]*max(w+1,3)

# q[0] = 1

# q[1] =1

# q[2]= 2

# for i in range(3,w+1):

# q[i] = (q[i-1]+q[i-2]+q[i-3]) % 1000

# print(q[w])


q =[0] * 10000000

arr = []

w =[ ]

def g(n):

if n == 1:

return 1

if n < len(q) and q[n] != 0:

return q[n]

if n % 2 == 1:

x = 3 *n +1

else:

x = n // 2

length = 1 + g(x)

if n < len(q):

q[n] = length

return length

a,b = map(int,input().split())

for i in range(a,b+1):

arr.append([i,g(i)])

w.append(g(i))

print(arr[w.index(max(w))][0],max(w))

2회 조회

마지막 메모리 초과

주소 : 경기도 용인시 광교중앙로 302 블루 스퀘어 602호
연락처 : 031) 216 - 1546 ,     031) 215 - 1546
사업자등록번호 : 465-92-00916
​학원 등록 제 4603호
bottom of page