結果

問題 No.731 等差数列がだいすき
ユーザー pluto77pluto77
提出日時 2018-09-09 15:26:39
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 168 ms / 1,500 ms
コード長 197 bytes
コンパイル時間 728 ms
コンパイル使用メモリ 10,592 KB
実行使用メモリ 30,992 KB
最終ジャッジ日時 2023-08-25 00:14:11
合計ジャッジ時間 7,427 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 147 ms
30,512 KB
testcase_01 AC 148 ms
30,472 KB
testcase_02 AC 145 ms
30,496 KB
testcase_03 AC 150 ms
30,412 KB
testcase_04 AC 154 ms
30,472 KB
testcase_05 AC 154 ms
30,652 KB
testcase_06 AC 142 ms
30,572 KB
testcase_07 AC 148 ms
30,568 KB
testcase_08 AC 155 ms
30,992 KB
testcase_09 AC 156 ms
30,516 KB
testcase_10 AC 168 ms
30,632 KB
testcase_11 AC 160 ms
30,552 KB
testcase_12 AC 164 ms
30,420 KB
testcase_13 AC 161 ms
30,844 KB
testcase_14 AC 158 ms
30,552 KB
testcase_15 AC 153 ms
30,724 KB
testcase_16 AC 139 ms
30,664 KB
testcase_17 AC 148 ms
30,648 KB
testcase_18 AC 142 ms
30,664 KB
testcase_19 AC 157 ms
30,576 KB
testcase_20 AC 150 ms
30,640 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#yuki731
import numpy as np

n=int(input())
l=np.array(list(map(float,input().split())))
a,b=np.polyfit(np.array(range(n)),l,1)
print(b,a)
res=0
for i in range(n):
 res+=(l[i]-b-a*i)**2
print(res)
0