https://school.programmers.co.kr/learn/courses/30/lessons/136798
for(int j=1; j*j<=num[i]; j++)
: 범위를 j<num[i]로 하면 시간초과가 발생하니 유의
class Solution {
public int solution(int number, int limit, int power) {
int answer = 0;
int[] num = new int[number];
for(int i=1; i<=number; i++){
num[i-1]=i;
}
List<Integer> list = new ArrayList<>();
for(int i=0; i<num.length;i++){
int count=0;
for(int j=1; j*j<=num[i]; j++){
if(i==0){
count++;
}
else if(j*j==num[i]){
count++;
}
else if(num[i]%j==0){
count+=2;
}
}
list.add(count);
}
for(int i=0; i<list.size(); i++){
if(list.get(i)<=limit){
answer+=list.get(i);
}
else{
answer+=power;
}
}
return answer;
}
}