結果

問題 No.800 四平方定理
ユーザー Ueki
提出日時 2019-03-17 23:30:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 261 ms / 2,000 ms
コード長 424 bytes
コンパイル時間 234 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 153,592 KB
最終ジャッジ日時 2024-07-08 03:30:27
合計ジャッジ時間 5,636 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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


def solve2():
    p = [x**2 for x in range(1, N+1)]
    cnt = [0]*10**7

    for w in p:
        for z in p:
            tmp = w-z+D
            if tmp > 0:
                cnt[tmp] += 1

    ans = 0
    for x in p:
        for y in p:
            ans += cnt[x+y]
    print(ans)


solve2()
0