結果
問題 |
No.1318 ABCD quadruplets
|
ユーザー |
![]() |
提出日時 | 2025-06-12 16:33:18 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,053 bytes |
コンパイル時間 | 343 ms |
コンパイル使用メモリ | 82,216 KB |
実行使用メモリ | 86,288 KB |
最終ジャッジ日時 | 2025-06-12 16:33:34 |
合計ジャッジ時間 | 5,185 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 11 TLE * 1 -- * 18 |
ソースコード
import sys from collections import defaultdict def main(): input = sys.stdin.read().split() N = int(input[0]) M = int(input[1]) # Precompute s_t_dict for c and d s_t_dict = defaultdict(lambda: defaultdict(int)) for c in range(M + 1): for d in range(M + 1): s = c + d t = c * c + c * d + d * d s_t_dict[s][t] += 1 ans = [0] * (N + 1) max_s = 2 * M for a in range(M + 1): for b in range(M + 1): k = a + b m = a * a + a * b + b * b for s in range(max_s + 1): if s not in s_t_dict: continue ks = k * s m_ks = m + ks if m_ks > N: continue t_dict = s_t_dict[s] for t, count in t_dict.items(): n = m_ks + t if n <= N: ans[n] += count for count in ans: print(count) if __name__ == '__main__': main()