結果

問題 No.800 四平方定理
ユーザー tamato
提出日時 2020-04-28 01:54:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,548 ms / 2,000 ms
コード長 530 bytes
コンパイル時間 345 ms
コンパイル使用メモリ 82,504 KB
実行使用メモリ 256,164 KB
最終ジャッジ日時 2024-11-22 20:05:26
合計ジャッジ時間 21,230 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000000007
eps = 10**-9


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

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

    cnt = {}
    for w in range(1, N+1):
        for z in range(1, N+1):
            if w*w - z*z in cnt:
                cnt[w*w - z*z] += 1
            else:
                cnt[w*w - z*z] = 1
    ans = 0
    for x in range(1, N+1):
        for y in range(1, N+1):
            if x*x + y*y - D in cnt:
                ans += cnt[x*x + y*y - D]
    print(ans)


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