結果
| 問題 | No.731 等差数列がだいすき |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-09-07 22:04:17 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,500 ms |
| コード長 | 639 bytes |
| コンパイル時間 | 1,990 ms |
| コンパイル使用メモリ | 168,948 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-29 13:46:16 |
| 合計ジャッジ時間 | 2,943 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cout<<setprecision(std::numeric_limits<float>::max_digits10);
ll n; cin>>n;
vector<ll> a(n);
rep(i,n) cin>>a[i];
ll C = 0;
rep(i,n) {
C+=i*a[i];
}
ll D = 0;
rep(i,n) {
D += a[i];
}
ll B = n*(n-1)/2;
ll A = n*(n-1)*(2*n-1)/6;
double b = 1.0*(A*D-B*C)/(n*A-B*B)*1.0;
double d = (D-n*b)/B;
double c = 0;
rep(i,n) {
double t = (b+i*d-a[i]);
c += t*t;
}
cout << b << " " << d << endl;
cout << c << endl;
return 0;
}