티스토리 뷰
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | let input = Int(readLine()!)! var array = [Int]() let maxFive = input / 5 for countFive in 0...maxFive{ var value = input value -= (countFive * 5) let countThree = value / 3 value -= (countThree * 3) if(value != 0){ array.append(-1) } else{ array.append(countThree + countFive) } } array = array.filter { $0 != -1 } if(array.count == 0){ print("-1") } else{ print(array.min()!) } | cs |
'Algorithm > Baekjoon Online Judge' 카테고리의 다른 글
| 2920번 '음계' (0) | 2018.02.23 |
|---|---|
| 2908번 '상수' (0) | 2018.02.23 |
| 2775번 '부녀회장이 될테야' (0) | 2018.02.23 |
| 2747번 '피보나치 수' (0) | 2018.02.23 |
| 2742번 '기찍 N' (0) | 2018.02.23 |
댓글
