20250718 baekjoon
This commit is contained in:
parent
4fcba77861
commit
0eb0f29c16
31
code_study/Baekjoon/python/17626.py
Normal file
31
code_study/Baekjoon/python/17626.py
Normal file
@ -0,0 +1,31 @@
|
||||
# n = int(input())
|
||||
# dp = [0] + [1 if i**0.5 % 1 == 0 else 0 for i in range(1,n+1)]
|
||||
# for i in range(2,n+1):
|
||||
# if dp[i] :
|
||||
# continue
|
||||
# k = 1
|
||||
# while k*k <= i :
|
||||
# if not dp[i] :
|
||||
# dp[i] = dp[i-k*k] + 1
|
||||
# else :
|
||||
# dp[i] = min(dp[i], dp[i-k*k] + 1)
|
||||
# k += 1
|
||||
# print(dp[n])
|
||||
|
||||
n = int(input())
|
||||
if n**0.5%1 == 0 :
|
||||
print(1)
|
||||
else :
|
||||
k = 1
|
||||
flag = False
|
||||
while k*k <= n :
|
||||
if (n - k*k)**0.5%1 == 0 :
|
||||
print(2)
|
||||
flag = True
|
||||
break
|
||||
k += 1
|
||||
|
||||
if not flag :
|
||||
while not n%4 :
|
||||
n //= 4
|
||||
print(4 if n%8==7 else 3)
|
||||
Loading…
x
Reference in New Issue
Block a user