Skip to content

Commit

Permalink
Merge pull request #186 from AlgoLeadMe/23-SeongHoonC
Browse files Browse the repository at this point in the history
23-SeongHoonC
  • Loading branch information
SeongHoonC authored May 17, 2024
2 parents a2a69c1 + b42bd35 commit 261aa3f
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
3 changes: 2 additions & 1 deletion SeongHoonC/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@
| 19μ°¨μ‹œ | 2024.04.04 | 그리디 | <a href="https://www.acmicpc.net/problem/16496">큰 수 λ§Œλ“€κΈ°</a> |https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/72 |
| 20μ°¨μ‹œ | 2024.04.07 | DP | <a href="https://www.acmicpc.net/problem/7579">μ•±</a> |https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/75 |
| 21μ°¨μ‹œ | 2024.04.11 | DP | <a href="https://www.acmicpc.net/problem/1149">RGB거리</a> |https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/77 |
| 21μ°¨μ‹œ | 2024.05.01 | DP | <a href="https://www.acmicpc.net/problem/11053">κ°€μž₯ κΈ΄ μ¦κ°€ν•˜λŠ” λΆ€λΆ„ μˆ˜μ—΄</a> |https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/80 |
| 22μ°¨μ‹œ | 2024.05.01 | DP | <a href="https://www.acmicpc.net/problem/11053">κ°€μž₯ κΈ΄ μ¦κ°€ν•˜λŠ” λΆ€λΆ„ μˆ˜μ—΄</a> |https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/80 |
| 23μ°¨μ‹œ | 2024.05.14 | ??? | <a href="https://www.acmicpc.net/problem/1644">μ†Œμˆ˜μ˜ 연속합</a> |https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/186 |
---
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import java.io.BufferedReader
import java.io.InputStreamReader
import kotlin.math.sqrt

fun main() {
val br = BufferedReader(InputStreamReader(System.`in`))
var (head, tail) = 0 to 0
val n = br.readLine().toInt()
val primes = findPrimeNumbers(n)
var count = 0

while (head < primes.size && tail < primes.size) {
val sum = primes.subList(head, tail + 1).sum()
if (sum < n) {
tail++
continue
}
if (sum == n) {
count++
}
head++
}
println(count)
}

private fun findPrimeNumbers(rangeMax: Int): List<Int> {
return (2..rangeMax).filter {
isPrime(it)
}
}

private fun isPrime(num: Int): Boolean {
for (i in 2..sqrt(num.toDouble()).toInt()) {
if (num % i == 0) {
return false
}
}
return true
}

0 comments on commit 261aa3f

Please sign in to comment.