[BOJ] 16199 - 나이 계산하기
node.js로 푼 것이 아니었다면 딱히 블로그에 올리지는 않았을 정도의 난이도.
소스코드
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
let i=0;
let birth=[];
let now=[];
rl.on('line', function(line) {
if(i==0){
birth=line.split(' ');
}
else if(i==1){
now = line.split(' ');
}
i+=1;
}).on("close", function() {
let ans=[0,0,0];
ans[2]=now[0]-birth[0];
ans[1]=ans[2]+1;
if(now[1]-birth[1]>0||(now[1]==birth[1]&&now[2]-birth[2]>=0)){
ans[0]=ans[2];
}
else ans[0]=ans[2]-1;
console.log(ans.join('\n'));
process.exit();
});
This post is licensed under CC BY 4.0 by the author.
Comments powered by Disqus.