結果
| 問題 | 
                            No.1318 ABCD quadruplets
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2022-10-09 08:45:45 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                TLE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 866 bytes | 
| コンパイル時間 | 210 ms | 
| コンパイル使用メモリ | 82,304 KB | 
| 実行使用メモリ | 82,764 KB | 
| 最終ジャッジ日時 | 2024-06-23 08:20:22 | 
| 合計ジャッジ時間 | 9,907 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 20 TLE * 1 -- * 9 | 
ソースコード
def solve(N, M):
    res = [0] * (N + 1)
    for a in range(M + 1):
        a_ = a ** 2
        for b in range(a, M + 1):
            b_ = b * (a + b)
            for c in range(b, M + 1):
                c_ = c * (a + b + c)
                for d in range(c, M + 1):
                    x = a_ + b_ + c_ + d * (a + b + c + d)
                    if x > N:
                        break
                    if a == b == c == d:
                        res[x] += 1
                    elif a == b == c or b == c == d:
                        res[x] += 4
                    elif a == b and c == d:
                        res[x] += 6
                    elif a == b or b == c or c == d:
                        res[x] += 12
                    else:
                        res[x] += 24
    return res
N, M = map(int, input().split())
print(*solve(N, M), sep="\n")