https://www.acmicpc.net/problem/2839
const fs = require('fs');
let input = fs.readFileSync('/dev/stdin').toString().split('\n');
const K = Number(input[0]);
let e = Math.floor(K/5);
let result = -1;
for(let i = e ; i >= 0 ; i--) {
let tmp = K - (i * 5);
if(tmp % 3 === 0) {
result = i + (tmp/3);
break;
}
}
console.log(result);
728x90
'Algorithm&CodingTest > Baekjoon' 카테고리의 다른 글
[ Baekjoon ] [13305] 실버 3 - 주유소 (0) | 2023.03.12 |
---|---|
[Baekjoon] [10814] 나이순 정렬 (0) | 2023.02.24 |
[Baekjoon] [1978] 실버4 - 소수찾기 (0) | 2023.02.24 |
[Baekjoon] [2754] 학점 계산 (0) | 2023.02.24 |
[Baekjoon] [2566] 브론즈3 - 최댓값 Node.js (0) | 2023.02.24 |