結果
| 問題 | No.1318 ABCD quadruplets |
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2026-02-11 01:27:53 |
| 言語 | JavaScript (node v25.6.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,373 bytes |
| 記録 | |
| コンパイル時間 | 304 ms |
| コンパイル使用メモリ | 8,224 KB |
| 実行使用メモリ | 58,612 KB |
| 最終ジャッジ日時 | 2026-02-11 01:28:02 |
| 合計ジャッジ時間 | 8,117 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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 main() {
const [N, M] = readLine().split(' ').map(x => parseInt(x, 10));
const result = new Array(N + 1).fill(0);
// Optimization: precompute contributions for (a,b) pairs
// a + ab + ac + ad + b + bc + bd + c + cd + d
// = (a + b) + (a+b)(c+d) + (c + d)
for (let a = 0; a <= M; a++) {
for (let b = 0; b <= M; b++) {
const ab_sum = a * a + a * b + b * b;
const ab_coef = a + b;
for (let c = 0; c <= M; c++) {
for (let d = 0; d <= M; d++) {
const cd_sum = c * c + c * d + d * d;
const cd_coef = c + d;
const value = ab_sum + ab_coef * cd_coef + cd_sum;
if (value <= N) {
result[value]++;
}
}
}
}
}
console.log(result.join(' '));
}
vjudge1