結果
| 問題 |
No.731 等差数列がだいすき
|
| コンテスト | |
| ユーザー |
merom686
|
| 提出日時 | 2018-09-10 12:37:25 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,500 ms |
| コード長 | 715 bytes |
| コンパイル時間 | 877 ms |
| コンパイル使用メモリ | 73,084 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-26 23:42:09 |
| 合計ジャッジ時間 | 1,843 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 |
ソースコード
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
ll c = 0, x = 0, y = 0, x2 = 0, y2 = 0;
for (int i = 0; i < n; i++) {
int a;
cin >> a;
c += i * a;
x += i;
y += a;
x2 += i * i;
y2 += (ll)a * a;
}
double a = (double)(n * c - x * y) / (n * x2 - x * x);
double b = (y - a * x) / n;
double t = a * a * x2 + 2 * a * b * x - 2 * a * c + y2 - 2 * b * y + b * b * n;
printf("%.9f %.9f\n%.9f\n", b, a, t);
return 0;
}
merom686