結果

問題 No.800 四平方定理
ユーザー hedwig100hedwig100
提出日時 2020-04-24 10:44:42
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,643 ms / 2,000 ms
コード長 368 bytes
コンパイル時間 99 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 167,340 KB
最終ジャッジ日時 2024-04-23 02:24:33
合計ジャッジ時間 33,150 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 452 ms
43,820 KB
testcase_01 AC 455 ms
44,060 KB
testcase_02 AC 461 ms
43,684 KB
testcase_03 AC 447 ms
43,940 KB
testcase_04 AC 455 ms
43,816 KB
testcase_05 AC 473 ms
43,556 KB
testcase_06 AC 467 ms
44,468 KB
testcase_07 AC 453 ms
43,696 KB
testcase_08 AC 455 ms
44,452 KB
testcase_09 AC 458 ms
44,236 KB
testcase_10 AC 1,062 ms
104,060 KB
testcase_11 AC 1,008 ms
112,088 KB
testcase_12 AC 1,046 ms
110,936 KB
testcase_13 AC 920 ms
107,256 KB
testcase_14 AC 960 ms
111,720 KB
testcase_15 AC 1,056 ms
111,496 KB
testcase_16 AC 992 ms
112,544 KB
testcase_17 AC 990 ms
112,580 KB
testcase_18 AC 1,105 ms
112,264 KB
testcase_19 AC 1,125 ms
112,420 KB
testcase_20 AC 444 ms
43,552 KB
testcase_21 AC 452 ms
43,684 KB
testcase_22 AC 1,141 ms
112,508 KB
testcase_23 AC 1,643 ms
167,340 KB
testcase_24 AC 1,453 ms
167,252 KB
testcase_25 AC 1,629 ms
167,060 KB
testcase_26 AC 463 ms
43,556 KB
testcase_27 AC 489 ms
43,680 KB
testcase_28 AC 1,448 ms
166,608 KB
testcase_29 AC 1,514 ms
166,884 KB
testcase_30 AC 1,444 ms
167,072 KB
testcase_31 AC 1,357 ms
158,436 KB
testcase_32 AC 1,454 ms
167,120 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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