-Code
class Solution {
public long solution(long n) {
double sqrt = Math.sqrt(n);
return sqrt == (long) sqrt ? (long) Math.pow(sqrt + 1, 2) : -1;
}
}
'Beakjoon&프로그래머스 > Java' 카테고리의 다른 글
[프로그래머스/Java] 음양 더하기 (1) | 2025.02.23 |
---|---|
[프로그래머스/Java] 하샤드 수 (0) | 2025.02.23 |
[프로그래머스/Java] 정수 내림차순으로 배치하기 (0) | 2025.02.23 |
[프로그래머스/Java] 문자열 내 p와 y의 개수 (0) | 2025.02.23 |
[프로그래머스/Java] 두 정수 사이의 합 (0) | 2025.02.23 |