結果

問題 No.1318 ABCD quadruplets
ユーザー H3PO4
提出日時 2022-10-09 09:11:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,301 ms / 2,000 ms
コード長 784 bytes
コンパイル時間 425 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 84,356 KB
最終ジャッジ日時 2024-06-23 08:41:03
合計ジャッジ時間 12,484 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

N, M = map(int, input().split())

res = [0] * (N + 1)
for a in range(M + 1):
    a_ = a ** 2
    for b in range(a, M + 1):
        b_ = b * (a + b)
        if a_ + b_ > N:
            break
        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

print(*res, sep="\n")
0