티스토리 뷰
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | import Foundation func isPrime(value: Int) -> Bool{ if(value == 1){ return false } var count = 0 for i in 1...Int(sqrt(Double(value))){ if(value % i == 0){ count += 1 } } if(count == 1){ return true } else{ return false } } var count = 0 _ = readLine() let input = readLine()?.split(separator: " ").map { Int($0)! } for i in input!{ if(isPrime(value: i)){ count += 1 } } print(count) | cs |
'Algorithm > Baekjoon Online Judge' 카테고리의 다른 글
2438번 '별 찍기 - 1' (0) | 2018.02.23 |
---|---|
2292번 '벌집' (0) | 2018.02.23 |
1977번 '완전제곱수' (0) | 2018.02.22 |
1924번 '2007년' (0) | 2018.02.22 |
1546번 '평균' (0) | 2018.02.22 |
댓글