結果

問題 No.731 等差数列がだいすき
ユーザー brthyyjpbrthyyjp
提出日時 2022-01-27 19:37:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 75 ms / 1,500 ms
コード長 326 bytes
コンパイル時間 1,140 ms
コンパイル使用メモリ 87,092 KB
実行使用メモリ 75,584 KB
最終ジャッジ日時 2023-08-26 21:27:20
合計ジャッジ時間 3,682 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,468 KB
testcase_01 AC 69 ms
71,268 KB
testcase_02 AC 69 ms
71,352 KB
testcase_03 AC 72 ms
75,320 KB
testcase_04 AC 74 ms
75,216 KB
testcase_05 AC 72 ms
75,188 KB
testcase_06 AC 75 ms
75,216 KB
testcase_07 AC 74 ms
75,460 KB
testcase_08 AC 74 ms
75,584 KB
testcase_09 AC 72 ms
75,276 KB
testcase_10 AC 74 ms
75,260 KB
testcase_11 AC 70 ms
71,332 KB
testcase_12 AC 72 ms
75,292 KB
testcase_13 AC 73 ms
75,528 KB
testcase_14 AC 75 ms
75,408 KB
testcase_15 AC 75 ms
75,216 KB
testcase_16 AC 74 ms
75,472 KB
testcase_17 AC 74 ms
75,320 KB
testcase_18 AC 75 ms
75,352 KB
testcase_19 AC 75 ms
75,220 KB
testcase_20 AC 74 ms
75,288 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
A = list(map(int, input().split()))

Sxx = sum([i**2 for i in range(n)])
Sx =  sum([i for i in range(n)])
Sy = sum([a for a in A])
Sxy = sum([i*a for i,a in enumerate(A)])

d = (n*Sxy-Sx*Sy)/(n*Sxx-Sx**2)
b = (Sxx*Sy-Sxy*Sx)/(n*Sxx-Sx**2)
c = sum([(a-d*i-b)**2 for i, a in enumerate(A)])
print(b, d)
print(c)
0