File tree Expand file tree Collapse file tree 2 files changed +15
-13
lines changed
프로그래머스/1/136798. 기사단원의 무기 Expand file tree Collapse file tree 2 files changed +15
-13
lines changed Original file line number Diff line number Diff line change 44
55### 성능 요약
66
7- 메모리: 78.2 MB, 시간: 15.27 ms
7+ 메모리: 98.9 MB, 시간: 122.34 ms
88
99### 구분
1010
1616
1717### 제출 일자
1818
19- 2025년 05월 11일 17:16:45
19+ 2025년 05월 11일 17:29:01
2020
2121### 문제 설명
2222
Original file line number Diff line number Diff line change 11class 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}
You can’t perform that action at this time.
0 commit comments