题解 | #编程题1#
编程题1
https://www.nowcoder.com/practice/ff518f3162c849b9a84d1fab8e7179be?tpId=182&tqId=34507&rp=1&ru=/exam/oj&qru=/exam/oj&sourceUrl=%2Fexam%2Foj%3Fpage%3D1%26tab%3D%25E5%2590%258D%25E4%25BC%2581%25E7%259C%259F%25E9%25A2%2598%26topicId%3D182&difficulty=undefined&judgeStatus=undefined&tags=&title=
const rl = require("readline").createInterface({ input: process.stdin }); var iter = rl[Symbol.asyncIterator](); const readline = async () => (await iter.next()).value; void async function () { // Write your code here while(line = await readline()){ lineInt = parseInt(line); while(lineInt--){ input = await readline(); input = input.split(' '); input = input.map(Number); n = input[0]; k = input[1]; d1 = Math.min(input[2], input[3]); d2 = Math.max(input[2], input[3]); case1 = k - (2*d1+d2); case2 = k - (2*d2+d1); case3 = k - (d2+d2-d1); case4 = k - (d2+d1); left = n-k; if(case1>=0 && case1%3==0){ need = d1+2*d2; if(need<=left&&(left-need)%3==0){ console.log('yes'); continue; } } if(case2>=0 && case2%3==0){ need = d2+2*d1; if(need <= left && (left-need)%3==0){ console.log('yes'); continue; } } if(case3>=0 && case3%3==0){ need = d1+d2; if(need<=left && (left-need)%3==0){ console.log('yes'); continue; } } if(case4>=0 && case4%3==0){ need = d2+d2-d1; if(need<=left && (left-need)%3==0){ console.log('yes'); continue; } } console.log('no'); } } }()