题解 | #百钱买百鸡问题#
百钱买百鸡问题
https://www.nowcoder.com/practice/74c493f094304ea2bda37d0dc40dc85b
求出其中两类鸡分别与另外一类鸡的关系方程式 条件设定为三类鸡数量都为整数即可 完整代码如下:
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()){ if (line) { let arr = Array.from(Array(21).keys()); let res = []; for (let i = 0; i < arr.length; i++){ let j = (100-7*i)/4; let k = (300+3*i)/4; if (j >= 0 && Number.isInteger(j) && k >= 0 && Number.isInteger(k)){ console.log(i, j, k); } } } } }()