結果
| 問題 | No.731 等差数列がだいすき |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-03-31 00:24:23 |
| 言語 | PyPy3 (7.3.23 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 68 ms / 1,500 ms |
| + 660µs | |
| コード長 | 501 bytes |
| 記録 | |
| コンパイル時間 | 236 ms |
| コンパイル使用メモリ | 95,688 KB |
| 実行使用メモリ | 78,768 KB |
| 最終ジャッジ日時 | 2026-09-02 08:22:56 |
| 合計ジャッジ時間 | 3,696 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 |
ソースコード
n = int(input())
a = list(map(float, input().split()))
points = []
mu_x = 0.0
mu_y = 0.0
cov_xy = 0.0
for i in range(n):
points.append((i, a[i]))
mu_x += i
mu_y += a[i]
cov_xy += i * a[i]
mu_x /= n
mu_y /= n
cov_xy = cov_xy / n - mu_x * mu_y
sigma2_x = 0.0
for x, y in points:
sigma2_x += (x - mu_x) ** 2
sigma2_x /= n
d = cov_xy / sigma2_x
b1 = mu_y - d * mu_x
c = sum([(b1 + i * d - points[i][1]) ** 2 for i in range(n)])
print("{:.7f} {:.7f}".format(b1, d))
print("{:.7f}".format(c))