백준 1322 nodejs

윤익·2022년 10월 30일
0

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

const fs = require('fs')
const input = fs.readFileSync('/dev/stdin').toString().trim().split('\n')
const [X, K] = input[0].split(' ').map(e => BigInt(e).toString(2))
let [Y, j] = ['', K.length - 1]
for (let i = X.length - 1; i >= 0; i--)
  if (X[i] == '1') Y = '0' + Y
  else Y = j >= 0 ? K[j--] + Y : '0' + Y
while (j >= 0) Y = K[j--] + Y
Y = BigInt('0b' + Y)
console.log(Y.toString())
profile
https://nickyoon.tistory.com/ 기술 블로그 이전

0개의 댓글