프로그래머스 - 주사위 게임 1

youngkyu MIn·2023년 9월 4일

문제링크 - 프로그래머스 - 주사위 게임 1


class Solution {
    public int solution(int a, int b) {

        int n = a+b;

        if(n%2==0) {

            if(a%2==0) {
                return Math.abs(a-b);
            } else {
                return  (int) (Math.pow(a,2) + Math.pow(b,2));
            }

        } else {
            return 2 * n;
        }
    }
}

좀 잘 푼거 같다 ㅋ 아님 말고

profile
한 줄 소개

0개의 댓글