結果

問題 No.800 四平方定理
ユーザー Navier_BoltzmannNavier_Boltzmann
提出日時 2023-11-17 23:27:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,305 ms / 2,000 ms
コード長 457 bytes
コンパイル時間 224 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 259,696 KB
最終ジャッジ日時 2023-11-17 23:27:50
合計ジャッジ時間 16,865 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
68,900 KB
testcase_01 AC 60 ms
74,988 KB
testcase_02 AC 57 ms
71,964 KB
testcase_03 AC 62 ms
72,596 KB
testcase_04 AC 66 ms
72,044 KB
testcase_05 AC 63 ms
73,184 KB
testcase_06 AC 67 ms
76,704 KB
testcase_07 AC 65 ms
76,600 KB
testcase_08 AC 69 ms
80,020 KB
testcase_09 AC 62 ms
73,876 KB
testcase_10 AC 509 ms
227,832 KB
testcase_11 AC 483 ms
227,724 KB
testcase_12 AC 531 ms
249,396 KB
testcase_13 AC 418 ms
208,992 KB
testcase_14 AC 433 ms
228,000 KB
testcase_15 AC 567 ms
249,344 KB
testcase_16 AC 475 ms
227,996 KB
testcase_17 AC 421 ms
227,792 KB
testcase_18 AC 701 ms
252,844 KB
testcase_19 AC 659 ms
252,972 KB
testcase_20 AC 41 ms
55,724 KB
testcase_21 AC 42 ms
55,724 KB
testcase_22 AC 649 ms
242,604 KB
testcase_23 AC 1,305 ms
250,560 KB
testcase_24 AC 952 ms
253,548 KB
testcase_25 AC 1,193 ms
250,480 KB
testcase_26 AC 41 ms
55,724 KB
testcase_27 AC 43 ms
55,724 KB
testcase_28 AC 850 ms
240,376 KB
testcase_29 AC 1,047 ms
243,356 KB
testcase_30 AC 909 ms
253,512 KB
testcase_31 AC 814 ms
259,696 KB
testcase_32 AC 977 ms
241,300 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *
from itertools import *
from functools import *
from heapq import *
import sys,math
input = sys.stdin.readline

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

A = defaultdict(int)
for i in range(1,N+1):
    i2 = i*i
    for j in range(1,min(math.ceil(math.sqrt(D+i2))+1,N)+1):
        j2 = j*j
        A[D + i2 - j2] += 1


ans = 0
for i in range(1,N+1):
    i2 = i*i
    for j in range(1,N+1):
        j2 = j*j
        ans += A[i2+j2]
print(ans)
0