Skip to content

Instantly share code, notes, and snippets.

@nattybear
Created Sep 22, 2022
Embed
What would you like to do?
백준 캡틴 이다솜
def cycleA(x):
n = 2
while True:
yield x
x = x + n
n += 1
def cycleB(x):
ys = cycleA(1)
next(ys)
while True:
yield x
y = next(ys)
x = x + y
def solution(n):
global z
xs = cycleB(1)
ys = []
for x in xs:
if n == x:
z += 1
return
if n < x:
y = ys.pop()
z += 1
return solution(n - y)
ys.append(x)
z = 0
n = int(input())
solution(n)
print(z)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment