結果
| 問題 | No.1318 ABCD quadruplets |
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2026-02-11 01:46:05 |
| 言語 | JavaScript (node v25.6.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,457 bytes |
| 記録 | |
| コンパイル時間 | 183 ms |
| コンパイル使用メモリ | 8,100 KB |
| 実行使用メモリ | 67,416 KB |
| 最終ジャッジ日時 | 2026-02-11 01:46:18 |
| 合計ジャッジ時間 | 7,264 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 3 |
| other | WA * 11 TLE * 1 -- * 18 |
ソースコード
process.stdin.resume();
process.stdin.setEncoding("utf-8");
let inputString = '';
let currentLine = 0;
process.stdin.on('data', (inputStdin) => {
inputString += inputStdin;
})
process.stdin.on('end', (_) => {
inputString = inputString.trim().split('\n').map(string => {
return string.trim();
});
main();
})
function readLine() {
return inputString[currentLine++];
}
function countTuples(N, M) {
// f[0..N]
const f = new Array(N + 1).fill(0);
// Precompute squares
const sq = new Array(M + 1);
for (let i = 0; i <= M; i++) {
sq[i] = i * i;
}
for (let a = 0; a <= M; a++) {
const a2 = sq[a];
for (let b = 0; b <= M; b++) {
const b2 = sq[b];
const ab = a * b;
for (let c = 0; c <= M; c++) {
const c2 = sq[c];
const ac = a * c;
const bc = b * c;
for (let d = 0; d <= M; d++) {
const s =
a2 + b2 + c2 + sq[d] +
ab + ac + a * d +
bc + b * d +
c * d;
if (s > N) break; // d only increases ? safe to break
f[s]++;
}
}
}
}
return f;
}
function main() {
const [N, M] = readLine().split(' ').map(Number);
const f = countTuples(N, M);
console.log(f.join(' '));
}
vjudge1