[BOJ 1978] ์์์ฐพ๊ธฐ
1. ๋ฌธ์ : Link
์์์ฐพ๊ธฐ
2. ํ์ด
1 -> ์ ์ธ
2 -> ํฌํจ
๊ทธ ์ธ ์ซ์๋ค์ 2~์๊ธฐ๊ฐ/2 ์ผ๋ก ๋๋ ์ ์ค ๋๋จธ์ง๊ฐ ์๋ค๋ฉด break
break๋ฌธ์ด ์คํ๋์ง ์์๋ค๋ฉด ์์์ด๊ธฐ ๋๋ฌธ์ append
3. ์ฝ๋
n = int(input())
arr = list(map(int, input().split()))
sosu = []
for a in arr:
if a == 1:
continue
if a == 2:
sosu.append(a)
continue
for i in range(2, a//2+1):
if a % i == 0:
break
else:
sosu.append(a)
print(len(sosu))
'๐ป Coding Problems Solving > Array | String | Loop' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[LeetCode] Two Sum (0) | 2022.06.30 |
---|---|
[BOJ 1789] ์๋ค์ ํฉ (0) | 2022.06.26 |
[BOJ 2693] N๋ฒ์งธ ํฐ ์ (0) | 2022.06.22 |
[BOJ 2609] ์ต๋๊ณต์ฝ์์ ์ต์๊ณต๋ฐฐ์ (0) | 2022.06.22 |
[BOJ 2501] ์ฝ์ ๊ตฌํ๊ธฐ (0) | 2022.06.03 |
์ต๊ทผ๋๊ธ