https://programmers.co.kr/learn/courses/30/lessons/12977
📒 문제
📒 코드
class Solution {
public int solution(int[] nums) {
int answer = 0;
int Pnum;
int cnt = 2;
boolean b = false;
for (int i = 0; i < nums.length - 2; i++) {
for (int k = i + 1; k < nums.length - 1; k++) {
for (int j = k + 1; j < nums.length; j++) {
Pnum = nums[i] + nums[k] + nums[j];
while (Pnum != 1 && Pnum / 2 > cnt) {
if (Pnum % cnt != 0) b = true;
else {
b = false;
break;
}
cnt++;
}
if (b == true) answer++;
cnt = 2;
}
}
}
return answer;
}
}