https://school.programmers.co.kr/learn/courses/30/lessons/12934?language=python3
import math
def solution(n):
x = math.sqrt(n)
xd = x // 1
if x == xd:
return (x + 1) * (x + 1)
else:
return -1
728x90
'🔍 알고리즘 > 프로그래머스 Python' 카테고리의 다른 글
[Python] 프로그래머스 12947. 하샤드 수 (Lv.1) (0) | 2022.09.29 |
---|---|
[Python] 프로그래머스 12916. 문자열 내 p와 y의 개수 (Lv.1) (0) | 2022.09.29 |
[Python] 프로그래머스 12932. 자연수 뒤집어 배열로 만들기 (Lv.1) (0) | 2022.09.29 |
[Python] 프로그래머스 12931. 자릿수 더하기 (Lv.1) (0) | 2022.09.27 |
[Python] 프로그래머스 12944. 평균 구하기 (Lv.1) (0) | 2022.09.27 |