Jayden1116 2022. 5. 18. 20:54
let fs = require('fs');
let path = process.platform === 'linux' ? '/dev/stdin' : './data.txt';

let input = fs.readFileSync(path).toString().trim().split(' ');

function solve(input) {
  let [fixPrice, perPrice, sellPrice] = input.map((x) => Number(x));

  if (perPrice - sellPrice >= 0) {
    return -1;
  } else {
    let count = Math.floor(fixPrice / (sellPrice - perPrice)) + 1;
    return count;
  }
}

console.log(solve(input));

๋ฐฑ์ค€


๋‹จ์ˆœํ•˜๊ฒŒ ์ƒ๊ฐํ•˜๋ฉด ๊ทธ๋ƒฅ ๋ฐ˜๋ณต๋ฌธ์„ ํ†ตํ•ด count๊ฐ’์„ ์–ป์–ด๋‚ผ ์ˆ˜ ์žˆ์ง€๋งŒ, ์‹์„ ์กฐ๊ธˆ๋งŒ ์† ๋ณด๋ฉด ๋ฐ˜๋ณต๋ฌธ ์—†์ด ํ›จ์”ฌ ๋น ๋ฅด๊ฒŒ ๊ณ„์‚ฐํ•ด๋‚ผ ์ˆ˜ ์žˆ๋‹ค.
์ด๋Ÿฐ ๋ถ€๋ถ„์ด ํ”„๋กœ๊ทธ๋ž˜๋ฐ์  ์‚ฌ๊ณ ์ธ์ง€๋Š” ์ •ํ™•์น˜ ์•Š์ง€๋งŒ, ๋ฌธ์ œ๊ฐ€ ๋‚˜ํƒ€๋‚ด๋Š” ๋ฐ”๋ฅผ ๋ช…ํ™•ํžˆ ์ดํ•ดํ•˜๊ณ  ํ’€์–ด๋‚˜๊ฐ€๋„๋ก ํ•˜์ž.