728x90
SMALL

using System;

public class Solution {
    public int solution(int n) {
        int answer = 0;
        if(Math.Sqrt(n)%1 == 0)
        {
            answer = 1;
        }
        else
        {
            answer = 2;
        }
        return answer;
    }
}

 

/////

 

def solution(n):
    if n**(1/2) == int(n**(1/2)) :
        return 1
    else :
        return 2

 

파이썬

 

def solution(n):
    return 1 if (n ** 0.5) % 1 == 0 else 2

 

 

def solution(n):
    if n**(1/2) == int(n**(1/2)) :
        return 1
    else :
        return 2

 

 

자바

 

 

class Solution {
    public int solution(int n) {
        
        if (n % Math.sqrt(n) == 0) 
        {
            return 1;
        } 
        else 
        {
            return 2;
        }
    }
}
728x90

설정

트랙백

댓글