题解 | 小红的正整数计数
小红的正整数计数
https://www.nowcoder.com/practice/bf1c0694fdb84d12bc03793dee837117
const rl = require("readline").createInterface({ input: process.stdin }); var iter = rl[Symbol.asyncIterator](); const readline = async () => (await iter.next()).value; void async function () { let line = await readline() line = line.split(' ').map(a=>parseInt(a)) let left = line[0] let right = line[1] let length = right-left+1 if(left%2===1 && right%2 === 1){ console.log((length-1)/2) }else if(left%2===0 && right%2===0){ console.log((length+1)/2) }else{ console.log(length/2) } }()
笨笨的方法之分类讨论