結果

問題 No.800 四平方定理
ユーザー titiatitia
提出日時 2019-03-17 22:38:01
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 354 ms / 2,000 ms
コード長 560 bytes
コンパイル時間 570 ms
コンパイル使用メモリ 87,368 KB
実行使用メモリ 202,216 KB
最終ジャッジ日時 2023-09-22 08:30:45
合計ジャッジ時間 7,817 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
77,360 KB
testcase_01 AC 98 ms
78,776 KB
testcase_02 AC 92 ms
77,748 KB
testcase_03 AC 91 ms
78,148 KB
testcase_04 AC 94 ms
77,848 KB
testcase_05 AC 95 ms
78,056 KB
testcase_06 AC 89 ms
79,220 KB
testcase_07 AC 89 ms
78,596 KB
testcase_08 AC 78 ms
79,144 KB
testcase_09 AC 90 ms
78,536 KB
testcase_10 AC 216 ms
138,988 KB
testcase_11 AC 204 ms
146,276 KB
testcase_12 AC 206 ms
145,400 KB
testcase_13 AC 180 ms
141,428 KB
testcase_14 AC 182 ms
146,032 KB
testcase_15 AC 206 ms
145,860 KB
testcase_16 AC 188 ms
146,644 KB
testcase_17 AC 188 ms
146,916 KB
testcase_18 AC 223 ms
147,056 KB
testcase_19 AC 220 ms
147,244 KB
testcase_20 AC 68 ms
71,300 KB
testcase_21 AC 70 ms
71,056 KB
testcase_22 AC 216 ms
147,556 KB
testcase_23 AC 354 ms
202,216 KB
testcase_24 AC 273 ms
201,328 KB
testcase_25 AC 307 ms
201,828 KB
testcase_26 AC 70 ms
71,272 KB
testcase_27 AC 67 ms
71,356 KB
testcase_28 AC 284 ms
201,500 KB
testcase_29 AC 297 ms
201,632 KB
testcase_30 AC 291 ms
201,632 KB
testcase_31 AC 269 ms
192,332 KB
testcase_32 AC 290 ms
201,908 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

PC=[0]*(2*N*N+1)
MC=[0]*(2*N*N+1)

for i in range(1,N+1):
    for j in range(i,N+1):
        if i==j:
            if D-N*N<=i*i+j*j<=D+N*N:
                PC[i*i+j*j]+=1
            MC[N*N]+=1
        else:
            if D-N*N<=i*i+j*j<=D+N*N:
                PC[i*i+j*j]+=2

            if 2-D<=i*i-j*j<=2*N*N-D:
                MC[i*i-j*j+N*N]+=1

            if 2-D<=-i*i+j*j<=2*N*N-D:
                MC[-i*i+j*j+N*N]+=1

ANS=0

for i in range(2,2*N*N+1):
    if 0<=i-D+N*N<=2*N*N:
        ANS+=PC[i]*MC[i-D+N*N]

print(ANS)
0