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๊ฐ์ ์ป์ด๋ผ ์ ์์ง๋ง, ์์ ์กฐ๊ธ๋ง ์ ๋ณด๋ฉด ๋ฐ๋ณต๋ฌธ ์์ด ํจ์ฌ ๋น ๋ฅด๊ฒ ๊ณ์ฐํด๋ผ ์ ์๋ค.
์ด๋ฐ ๋ถ๋ถ์ด ํ๋ก๊ทธ๋๋ฐ์ ์ฌ๊ณ ์ธ์ง๋ ์ ํ์น ์์ง๋ง, ๋ฌธ์ ๊ฐ ๋ํ๋ด๋ ๋ฐ๋ฅผ ๋ช
ํํ ์ดํดํ๊ณ ํ์ด๋๊ฐ๋๋ก ํ์.
'๐ JavaScript > ๋ฐฑ์ค' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[JS] 1193 (0) | 2022.05.18 |
---|---|
[JS] 2292 (0) | 2022.05.18 |
[JS] 1316 (0) | 2022.05.18 |
[JS] 2941 (0) | 2022.05.18 |
[JS] 5622 (0) | 2022.05.18 |