๐ JavaScript/๋ฐฑ์ค
[JS] 1712
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๊ฐ์ ์ป์ด๋ผ ์ ์์ง๋ง, ์์ ์กฐ๊ธ๋ง ์ ๋ณด๋ฉด ๋ฐ๋ณต๋ฌธ ์์ด ํจ์ฌ ๋น ๋ฅด๊ฒ ๊ณ์ฐํด๋ผ ์ ์๋ค.
์ด๋ฐ ๋ถ๋ถ์ด ํ๋ก๊ทธ๋๋ฐ์ ์ฌ๊ณ ์ธ์ง๋ ์ ํ์น ์์ง๋ง, ๋ฌธ์ ๊ฐ ๋ํ๋ด๋ ๋ฐ๋ฅผ ๋ช
ํํ ์ดํดํ๊ณ ํ์ด๋๊ฐ๋๋ก ํ์.