알고리즘 문제

알고리즘 문제 js 49- 설탕 배달 (백준2839)

<zinny/> 2022. 3. 3. 11:35
728x90

내가 쓴 코드 

const fs = require('fs')
const input = Number(fs.readFileSync("./dev/stdin").toString())

let N = Number(input);
let five = 0;
let three = 0;

while(true){
    if(N % 5 === 0){
        five = N / 5;
        console.log(five + three);
        break;
    }
    if(N < 0){
        console.log(-1);
        break;
    }
    N = N - 3;
    three++;
}
728x90