第二题先是用回溯,超时了,后面改了一下,我感觉我是对的,但是感觉有个点被卡了,导致没a😓,有大佬帮忙看下吗 void (async function () { // Write your code here let line1 = await readline(); const n = +line1; let line2 = await readline(); const arr = line2.split(" ").map((i) => +i); let res = new Array(10).fill(0); res[arr[n - 1] % 10]++; // console.log(res) for (let i = n - 2; i >= 0; --i) { let tmp = new Array(10).fill(0); res.forEach((w, idx) => { tmp[(idx + arr[i]) % 10] += w; tmp[(idx * arr[i]) % 10] += w; }); res = tmp; } console.log(res.join(" ")); })();
1 3

相关推荐

牛客网
牛客企业服务