結果

問題 No.1318 ABCD quadruplets
ユーザー 👑 tamatotamato
提出日時 2020-12-15 10:57:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 762 ms / 2,000 ms
コード長 2,556 bytes
コンパイル時間 225 ms
コンパイル使用メモリ 81,960 KB
実行使用メモリ 84,320 KB
最終ジャッジ日時 2023-10-20 05:52:55
合計ジャッジ時間 8,958 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,684 KB
testcase_01 AC 36 ms
53,684 KB
testcase_02 AC 37 ms
53,684 KB
testcase_03 AC 36 ms
53,684 KB
testcase_04 AC 37 ms
53,684 KB
testcase_05 AC 38 ms
53,684 KB
testcase_06 AC 38 ms
53,684 KB
testcase_07 AC 36 ms
53,684 KB
testcase_08 AC 36 ms
53,684 KB
testcase_09 AC 37 ms
53,684 KB
testcase_10 AC 37 ms
53,684 KB
testcase_11 AC 37 ms
53,684 KB
testcase_12 AC 36 ms
53,684 KB
testcase_13 AC 92 ms
76,384 KB
testcase_14 AC 363 ms
82,548 KB
testcase_15 AC 84 ms
76,224 KB
testcase_16 AC 407 ms
81,296 KB
testcase_17 AC 99 ms
79,948 KB
testcase_18 AC 325 ms
82,384 KB
testcase_19 AC 179 ms
83,124 KB
testcase_20 AC 92 ms
76,408 KB
testcase_21 AC 126 ms
78,048 KB
testcase_22 AC 95 ms
80,896 KB
testcase_23 AC 762 ms
83,768 KB
testcase_24 AC 709 ms
83,768 KB
testcase_25 AC 230 ms
83,528 KB
testcase_26 AC 154 ms
82,736 KB
testcase_27 AC 567 ms
83,788 KB
testcase_28 AC 256 ms
84,320 KB
testcase_29 AC 304 ms
83,740 KB
testcase_30 AC 760 ms
84,056 KB
testcase_31 AC 240 ms
83,792 KB
testcase_32 AC 762 ms
84,056 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    def f(a, b, c, d):
        return (a+b+c+d) ** 2 - (a+b) * (c+d) - a*b - c*d

    N, M = map(int, input().split())
    ans = [0] * (N+1)
    for d in range(M+1):
        if f(d+3, d+2, d+1, d) > N:
            break
        for c in range(d+1, M+1):
            if f(c+2, c+1, c, d) > N:
                break
            for b in range(c+1, M+1):
                if f(b+1, b, c, d) > N:
                    break
                for a in range(b+1, M+1):
                    x = f(a, b, c, d)
                    if x > N:
                        break
                    ans[x] += 24

    # d==c
    for d in range(M+1):
        if f(d+2, d+1, d, d) > N:
            break
        for b in range(d+1, M+1):
            if f(b+1, b, d, d) > N:
                break
            for a in range(b+1, M+1):
                x = f(a, b, d, d)
                if x > N:
                    break
                ans[x] += 12

    # c==b
    for d in range(M+1):
        if f(d+2, d+1, d+1, d) > N:
            break
        for c in range(d+1, M+1):
            if f(c+1, c, c, d) > N:
                break
            for a in range(c+1, M+1):
                x = f(a, c, c, d)
                if x > N:
                    break
                ans[x] += 12

    # b==a
    for d in range(M+1):
        if f(d+2, d+2, d+1, d) > N:
            break
        for c in range(d+1, M+1):
            if f(c+1, c+1, c, d) > N:
                break
            for b in range(c+1, M+1):
                x = f(b, b, c, d)
                if x > N:
                    break
                ans[x] += 12

    # d==c, b==a
    for d in range(M+1):
        if f(d+1, d+1, d, d) > N:
            break
        for b in range(d+1, M+1):
            x = f(b, b, d, d)
            if x > N:
                break
            ans[x] += 6

    # d==c==b
    for d in range(M+1):
        if f(d+1, d, d, d) > N:
            break
        for a in range(d+1, M+1):
            x = f(a, d, d, d)
            if x > N:
                break
            ans[x] += 4

    # c==b==a
    for d in range(M+1):
        if f(d+1, d+1, d+1, d) > N:
            break
        for c in range(d+1, M+1):
            x = f(c, c, c, d)
            if x > N:
                break
            ans[x] += 4

    #a==b==c==d:
    for d in range(M+1):
        x = f(d, d, d, d)
        if x > N:
            break
        ans[x] += 1
    print(*ans, sep="\n")


if __name__ == '__main__':
    main()
0