import java.lang.Math;
class Solution {
public int solution(int a, int b, int c) {
int answer = 0;
if(a!=b && b!=c && a!=c){
answer=a+b+c;
}
else if(a==b&& b==c&& a==c){
answer = (a+b+c)*(int)(Math.pow(a,2)+Math.pow(b,2)+Math.pow(c,2))*(int)(Math.pow(a,3)+Math.pow(b,3)+Math.pow(c,3));
}
else{
answer = (a+b+c)*(int)(Math.pow(a,2)+Math.pow(b,2)+Math.pow(c,2));
}
return answer;
}
}
Math.pow는 double을 return하기 때문에 int로 downcasting해줘야합니당
'코딩테스트 > lv0' 카테고리의 다른 글
[프로그래머스 코딩테스트] java Lv.0 이어붙인 수 (1) | 2024.10.17 |
---|---|
[프로그래머스 코딩테스트] java Lv.0 원소들의 곱과 합 (0) | 2024.10.17 |
[프로그래머스 코딩테스트] java Lv.0 등차수열의 특정한 항만 더하기 (0) | 2024.10.17 |
[프로그래머스 코딩테스트] java Lv.0 코드처리하기 (0) | 2024.10.17 |
[프로그래머스 코딩테스트] java Lv.0 겹치는 선분의 길이 (0) | 2024.08.27 |