백준 1644 nodejs

윤익·2022년 11월 16일
0

https://www.acmicpc.net/problem/1644

const N = +require('fs').readFileSync('./dev/stdin').toString()
const [A, visited] = [[], Array(N + 1).fill(0)]
for (let i = 2; i <= N; i++) {
  if (visited[i]) continue
  A.push(i)
  for (let j = 1; i * j <= N; j++) visited[i * j] = 1
}
let [l, O, n, i, j] = [A.length, 0, 0, 0, 0]
while (n >= 0)
  if (n < N) n += A[j++]
  else {
    if (n == N) O++
    n -= A[i++]
  }
console.log(O)
profile
https://nickyoon.tistory.com/ 기술 블로그 이전

0개의 댓글

관련 채용 정보