File tree Expand file tree Collapse file tree 2 files changed +17
-15
lines changed
Expand file tree Collapse file tree 2 files changed +17
-15
lines changed Original file line number Diff line number Diff line change 44
55### 성능 요약
66
7- 메모리: 10.3 MB, 시간: 10.09 ms
7+ 메모리: 9.48 MB, 시간: 5.91 ms
88
99### 구분
1010
1616
1717### 제출 일자
1818
19- 2024년 09월 05일 21:21:10
19+ 2025년 04월 12일 13:33:59
2020
2121### 문제 설명
2222
Original file line number Diff line number Diff line change 11from itertools import permutations
22
3+ def isPrime (n ):
4+ for i in range (2 , int (n ** 0.5 )+ 1 ):
5+ if n % i == 0 :
6+ return False
7+ return True
8+
39def solution (numbers ):
4- ans = []
5- nums = [n for n in numbers ]
6- per = []
7- for i in range (1 , len (numbers ) + 1 ):
8- per += list (permutations (nums , i ))
9- new_nums = set ([int (("" ).join (p )) for p in per ]) - {0 , 1 }
10+ A = set ()
11+ for i in range (1 , len (numbers )+ 1 ):
12+ for j in permutations (list (numbers ), i ):
13+ A .add (int ("" .join (j )))
1014
11- cnt = len (new_nums )
12- for n in new_nums :
13- for i in range (2 , int (n ** 0.5 ) + 1 ):
14- if n % i == 0 :
15- cnt -= 1
16- break
17- return cnt
15+ cnt = 0
16+ for i in A :
17+ if 2 <= i and isPrime (i ):
18+ cnt += 1
19+ return cnt
You can’t perform that action at this time.
0 commit comments