結果
| 問題 | No.731 等差数列がだいすき |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-09-17 13:57:36 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 444 bytes |
| 記録 | |
| コンパイル時間 | 76 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 43,948 KB |
| 最終ジャッジ日時 | 2024-07-18 07:38:45 |
| 合計ジャッジ時間 | 11,965 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | RE * 3 |
| other | RE * 18 |
ソースコード
import numpy as np
n = int(input())
LST = []
mean1 = 0
for x in input().split():
x = int(x)
mean1 += x
LST.append(x)
mean1 /= n
mean2 = (n - 1) / 2
LST = np.array(LST) - mean1
L2 = np.array(range(n)) - mean2
Sxy = 0
Sx2 = 0
for i in range(n):
Sxy += LST[i] * L2[i]
Sx2 += L2[i] ** 2
d = Sxy / Sx2
b = mean1 - a * mean2
LST += mean1
ai = b
cost = 0
for x in LST:
cost += (x - ai) ** 2
ai += d
print(b, d)
print(cost)