結果

問題 No.731 等差数列がだいすき
ユーザー kimiyukikimiyuki
提出日時 2018-09-07 21:37:19
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 164 ms / 1,500 ms
コード長 205 bytes
コンパイル時間 103 ms
コンパイル使用メモリ 10,684 KB
実行使用メモリ 32,264 KB
最終ジャッジ日時 2023-08-19 12:54:40
合計ジャッジ時間 6,847 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 164 ms
30,472 KB
testcase_01 AC 135 ms
30,428 KB
testcase_02 AC 137 ms
32,104 KB
testcase_03 AC 136 ms
30,884 KB
testcase_04 AC 135 ms
30,676 KB
testcase_05 AC 135 ms
30,436 KB
testcase_06 AC 138 ms
30,612 KB
testcase_07 AC 135 ms
30,804 KB
testcase_08 AC 135 ms
30,488 KB
testcase_09 AC 139 ms
32,264 KB
testcase_10 AC 134 ms
32,160 KB
testcase_11 AC 135 ms
32,104 KB
testcase_12 AC 134 ms
30,780 KB
testcase_13 AC 135 ms
30,584 KB
testcase_14 AC 135 ms
30,492 KB
testcase_15 AC 135 ms
30,680 KB
testcase_16 AC 137 ms
30,392 KB
testcase_17 AC 135 ms
30,476 KB
testcase_18 AC 136 ms
32,076 KB
testcase_19 AC 135 ms
30,556 KB
testcase_20 AC 138 ms
30,612 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np
n = int(input())
a = np.array(list(map(float, input().split())))
b, d = np.polyfit(np.array(range(n)), a, 1)
print(d, b)
print(sum([ (d + b * i - a_i) ** 2 for i, a_i in enumerate(a) ]))
0