백준 3079 nodejs

윤익·2022년 11월 4일
0

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

const fs = require('fs')
const input = fs.readFileSync('/dev/stdin').toString().trim().split('\n')
const [N, M] = input.shift().split(' ').map(BigInt)
const A = input.map(BigInt)
let [L, R] = [1n, 10n ** 9n * M]
while (L < R) {
  const C = BigInt((L + R) / 2n)
  const S = A.reduce((a, b) => a + BigInt(C / b), 0n)
  S < M ? (L = C + 1n) : (R = C)
}
console.log(R.toString())
profile
https://nickyoon.tistory.com/ 기술 블로그 이전

0개의 댓글