結果

問題 No.1318 ABCD quadruplets
ユーザー 👑 tatyam
提出日時 2020-07-24 23:50:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,381 ms / 2,000 ms
コード長 834 bytes
コンパイル時間 295 ms
コンパイル使用メモリ 82,212 KB
実行使用メモリ 79,952 KB
最終ジャッジ日時 2024-06-25 23:07:28
合計ジャッジ時間 12,443 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m = map(int, input().split())

ans = [0]*(n+1)
for a in range(m + 1):
    for b in range(a,m + 1):
        if a * a + (a + b) * b > n:
            break
        for c in range(b,m + 1):
            if a * a + (a + b) * b + (a + b + c) * c > n:
                break
            for d in range(c,m + 1):
                s = a * a + (a + b) * b + (a + b + c) * c + (a + b + c + d) * d
                if s > n:
                    break
                if a == b == c == d:
                    ans[s] += 1
                elif a == b == c or b == c == d:
                    ans[s] += 4
                elif a == b and c == d:
                    ans[s] += 6
                elif a == b or b == c or c == d:
                    ans[s] += 12
                else:
                    ans[s] += 24
print("\n".join(str(i) for i in ans))
0