Bomb Kirby Running
Cat Life - GT-K
12934번 정수 제곱근 판별

2023. 3. 20. 09:21Programmers

코딩테스트 연습 - Level 1 - 정수 제곱근 판별

https://programmers.co.kr/learn/courses/30/lessons/12934

#include <string>
#include <vector>
#include <cmath>

using namespace std;

long long solution(long long n) {
    long long answer = 0;    
    
    if(sqrt(n)==(int)sqrt(n))
    {
        answer=pow(sqrt(n)+1,2);
    }
    
    else
    {
        answer=-1;
    }    
    
    return answer;
}