結果

問題 No.800 四平方定理
ユーザー hedwig100hedwig100
提出日時 2020-04-24 10:56:00
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 654 ms / 2,000 ms
コード長 343 bytes
コンパイル時間 600 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 170,688 KB
最終ジャッジ日時 2024-04-23 02:26:16
合計ジャッジ時間 18,538 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 455 ms
45,092 KB
testcase_01 AC 450 ms
45,620 KB
testcase_02 AC 450 ms
45,216 KB
testcase_03 AC 453 ms
45,356 KB
testcase_04 AC 450 ms
45,096 KB
testcase_05 AC 448 ms
45,344 KB
testcase_06 AC 468 ms
46,744 KB
testcase_07 AC 482 ms
46,644 KB
testcase_08 AC 463 ms
46,868 KB
testcase_09 AC 464 ms
45,476 KB
testcase_10 AC 513 ms
107,588 KB
testcase_11 AC 513 ms
114,500 KB
testcase_12 AC 525 ms
113,680 KB
testcase_13 AC 510 ms
109,336 KB
testcase_14 AC 520 ms
114,220 KB
testcase_15 AC 527 ms
113,912 KB
testcase_16 AC 520 ms
116,096 KB
testcase_17 AC 534 ms
115,040 KB
testcase_18 AC 529 ms
114,832 KB
testcase_19 AC 528 ms
115,484 KB
testcase_20 AC 447 ms
44,464 KB
testcase_21 AC 448 ms
44,456 KB
testcase_22 AC 528 ms
114,964 KB
testcase_23 AC 612 ms
169,592 KB
testcase_24 AC 587 ms
169,384 KB
testcase_25 AC 601 ms
169,592 KB
testcase_26 AC 459 ms
44,200 KB
testcase_27 AC 445 ms
44,452 KB
testcase_28 AC 654 ms
169,948 KB
testcase_29 AC 586 ms
170,364 KB
testcase_30 AC 582 ms
169,968 KB
testcase_31 AC 585 ms
162,168 KB
testcase_32 AC 609 ms
170,688 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np
def main():
    n,d = map(int,input().split())
    square = np.arange(1,n + 1) ** 2
    Add = np.bincount(np.add.outer(square,square).flatten(),minlength = 10 ** 7)
    Sub = (square[:,None] - square[None,:]).flatten() + d
    Sub = Sub[Sub >= 0]
    ans = Add[Sub].sum()
    print(ans)
if __name__ =='__main__':
    main() 
0