본문 바로가기
코테/코테withJS

백준 1476번 날짜 계산

by 트레일헤드레인저 2022. 7. 4.
SMALL

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

 

let input = require('fs').readFileSync('/dev/stdin').toString().trim().split(' ').map(e => +e);
let [e, s, m] = [...input];
let count = 1;
while (1) {
  if (
    (count - e) % 15 === 0 &&
    (count - s) % 28 === 0 &&
    (count - m) % 19 === 0
  ) {
    console.log(count);
    break;
  }
  count++;
}

코드보다 문제 이해하는게 더 어려운거같은데... 뭐지?

 

근데 저 코드로 제출하면 메모리초과가 뜬다. 브루트하지않은녀석

 

https://kscodebase.tistory.com/416

 

[node.js] 날짜 계산 ( 백준 1476번 )

const readline = require("readline"); const rl = readline.createInterface({ input: process.stdin, output: process.stdout, }); rl.on("line", (line) => { const [E, S, M] = line.split(" ").map(Number);..

kscodebase.tistory.com

저 블로그 보면 입력값을 다르게 처리하면되나..?

LIST