結果

問題 No.800 四平方定理
ユーザー titiatitia
提出日時 2019-03-17 22:38:01
言語 PyPy3
(7.3.8)
結果
AC  
実行時間 395 ms / 2,000 ms
コード長 560 bytes
コンパイル時間 252 ms
使用メモリ 206,788 KB
最終ジャッジ日時 2023-02-11 09:39:52
合計ジャッジ時間 9,518 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 104 ms
81,752 KB
testcase_01 AC 119 ms
83,308 KB
testcase_02 AC 109 ms
82,480 KB
testcase_03 AC 109 ms
82,516 KB
testcase_04 AC 114 ms
82,160 KB
testcase_05 AC 114 ms
82,468 KB
testcase_06 AC 110 ms
83,632 KB
testcase_07 AC 109 ms
82,924 KB
testcase_08 AC 95 ms
83,644 KB
testcase_09 AC 104 ms
83,220 KB
testcase_10 AC 247 ms
143,292 KB
testcase_11 AC 258 ms
151,176 KB
testcase_12 AC 266 ms
149,956 KB
testcase_13 AC 231 ms
146,268 KB
testcase_14 AC 238 ms
150,940 KB
testcase_15 AC 269 ms
150,576 KB
testcase_16 AC 240 ms
151,712 KB
testcase_17 AC 239 ms
151,988 KB
testcase_18 AC 273 ms
151,360 KB
testcase_19 AC 274 ms
151,916 KB
testcase_20 AC 84 ms
75,396 KB
testcase_21 AC 82 ms
75,740 KB
testcase_22 AC 274 ms
151,428 KB
testcase_23 AC 395 ms
206,232 KB
testcase_24 AC 346 ms
206,316 KB
testcase_25 AC 387 ms
205,884 KB
testcase_26 AC 84 ms
75,444 KB
testcase_27 AC 83 ms
75,744 KB
testcase_28 AC 359 ms
205,856 KB
testcase_29 AC 374 ms
206,196 KB
testcase_30 AC 351 ms
205,996 KB
testcase_31 AC 328 ms
197,332 KB
testcase_32 AC 363 ms
206,788 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