Skip to content

Commit 4ac63d7

Browse files
committed
[level 1] Title: 기사단원의 무기, Time: 122.34 ms, Memory: 98.9 MB -BaekjoonHub
1 parent bbea9b5 commit 4ac63d7

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

프로그래머스/1/136798. 기사단원의 무기/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
### 성능 요약
66

7-
메모리: 78.2 MB, 시간: 15.27 ms
7+
메모리: 98.9 MB, 시간: 122.34 ms
88

99
### 구분
1010

@@ -16,7 +16,7 @@
1616

1717
### 제출 일자
1818

19-
2025년 05월 11일 17:16:45
19+
2025년 05월 11일 17:29:01
2020

2121
### 문제 설명
2222

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
class Solution {
2-
32
public int solution(int number, int limit, int power) {
4-
int[] count = new int[number + 1];
5-
for (int i = 1; i <= number; i++) {
6-
for (int j = 1; j <= number / i; j++) {
7-
count[i * j]++;
8-
}
9-
}
103
int answer = 0;
11-
for (int i = 1; i <= number; i++) {
12-
if (count[i] > limit) {
4+
for(int i=1; i<=number; i++){
5+
int a = count(i);
6+
if(a>limit){
137
answer += power;
14-
} else {
15-
answer += count[i];
8+
}else{
9+
answer += a;
1610
}
1711
}
1812
return answer;
1913
}
14+
public int count(int N){
15+
int count = 0;
16+
for (int i = 1; i * i <= N; i++) {
17+
if (i * i == N) count++;
18+
else if (N % i == 0) count += 2;
19+
}
20+
return count;
21+
}
2022
}

0 commit comments

Comments
 (0)