結果

問題 No.731 等差数列がだいすき
ユーザー minamiminami
提出日時 2019-04-04 17:07:15
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 128 ms / 1,500 ms
コード長 202 bytes
コンパイル時間 69 ms
コンパイル使用メモリ 10,556 KB
実行使用メモリ 32,644 KB
最終ジャッジ日時 2023-08-26 21:27:50
合計ジャッジ時間 5,759 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
30,528 KB
testcase_01 AC 126 ms
30,408 KB
testcase_02 AC 126 ms
30,884 KB
testcase_03 AC 126 ms
31,960 KB
testcase_04 AC 125 ms
30,432 KB
testcase_05 AC 126 ms
30,520 KB
testcase_06 AC 126 ms
30,696 KB
testcase_07 AC 125 ms
30,592 KB
testcase_08 AC 126 ms
30,664 KB
testcase_09 AC 125 ms
32,032 KB
testcase_10 AC 125 ms
30,764 KB
testcase_11 AC 124 ms
30,460 KB
testcase_12 AC 123 ms
32,188 KB
testcase_13 AC 124 ms
30,592 KB
testcase_14 AC 125 ms
30,504 KB
testcase_15 AC 126 ms
30,728 KB
testcase_16 AC 124 ms
30,492 KB
testcase_17 AC 126 ms
30,652 KB
testcase_18 AC 126 ms
30,700 KB
testcase_19 AC 128 ms
32,508 KB
testcase_20 AC 126 ms
32,644 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np
N = int(input())
y = list(map(int, input().split()))
x = [i for i in range(N)]

a, b = np.polyfit(x, y, 1)
c = sum((_y - a*_x - b) ** 2 for _x, _y in zip(x, y))

print(b, a)
print(c)
0