結果

問題 No.731 等差数列がだいすき
ユーザー rookzenorookzeno
提出日時 2018-09-08 23:03:17
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 139 ms / 1,500 ms
コード長 410 bytes
コンパイル時間 258 ms
コンパイル使用メモリ 11,004 KB
実行使用メモリ 31,692 KB
最終ジャッジ日時 2023-08-23 07:46:52
合計ジャッジ時間 6,102 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
29,952 KB
testcase_01 AC 134 ms
31,500 KB
testcase_02 AC 132 ms
30,020 KB
testcase_03 AC 132 ms
30,160 KB
testcase_04 AC 134 ms
30,020 KB
testcase_05 AC 135 ms
30,080 KB
testcase_06 AC 139 ms
29,968 KB
testcase_07 AC 135 ms
29,940 KB
testcase_08 AC 138 ms
30,060 KB
testcase_09 AC 137 ms
30,084 KB
testcase_10 AC 137 ms
31,692 KB
testcase_11 AC 134 ms
29,976 KB
testcase_12 AC 133 ms
29,968 KB
testcase_13 AC 133 ms
29,892 KB
testcase_14 AC 133 ms
29,952 KB
testcase_15 AC 135 ms
30,064 KB
testcase_16 AC 134 ms
30,000 KB
testcase_17 AC 135 ms
30,020 KB
testcase_18 AC 133 ms
30,068 KB
testcase_19 AC 139 ms
30,084 KB
testcase_20 AC 135 ms
31,580 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np
n = int(input())
a = list(map(int,input().split()))
su1 = (sum(a)*2)
b1 = n*2
d1 = (0+2*(n-1))*n//2
su2 = 0
b2 = 0
d2 = 0
for i in range(n):
  su2 += a[i] * (i)*2
  b2 += (i)*2
  d2 += ((i)**2)*2
kake = np.array([[b1,d1],[b2,d2]])
ans = np.array([su1,su2])
ans = np.dot(np.linalg.inv(kake),ans)
print(ans[0],ans[1])
kota = 0
for i in range(n):
  kota += (a[i]-ans[0]-ans[1]*i)**2
print(kota)
0