← Back to List

17252번: 삼삼한 수 ↗

Solutions

Python 3
196 B | 196 chars
L = [1]
for i in range(22):
    L.append(L[-1]*3)
cnt=0
n = int(input())
for i in L[::-1]:
    if i <= n:
        cnt+=1
        n -=i
if n == 0 and cnt > 0:
    print("YES")
else:
    print("NO")