[프로그래머스]주사위 게임

박예림·2023년 5월 25일
0

코테

목록 보기
125/132

class Solution {
    public int solution(int a, int b) {
        int answer = 0;
        
        if (a%2 != 0 && b%2 != 0){
            answer = (int) (Math.pow(a,2) + Math.pow(b,2));
        } else if (a%2 != 0 || b%2 != 0) {
            answer = 2*(a+b);
        } else {
            answer = Math.abs(a-b);
        }
        
        return answer;
    }
}
profile
응애 나 아기개발자

0개의 댓글