-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10014.cpp
More file actions
38 lines (36 loc) · 820 Bytes
/
10014.cpp
File metadata and controls
38 lines (36 loc) · 820 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <iostream>
//#include <cmath>
using namespace std;
/*
an+ =2an+2cn-an-;
an+-an=an-an- + 2cn;
let bn=an+-an;
bn=bn-+cn;
bn=\sum cn +b0;
\sumbn=an+-a0=\sum\sum cn+b0.
b0=a1-a0 is solvable.
*/
//double a[1000+10];
double c[3000+100];
int main(){
int kase;
cin>>kase;
cout.setf(ios::fixed,ios::floatfield);
cout.precision(2);
int first=true;
for(int i=0;i<kase;i++){
if(first)first=false; else cout<<endl;
int n;
cin>>n;
double a0,ae;
cin>>a0>>ae;
for(int i=1;i<=n;i++) cin>>c[i];
double sum=0;
for(int i=1;i<=n;i++) sum+=2*c[i]*(n+1-i);
double b0=(ae-a0-sum)/(n+1);
//a[0]=a0;a[1]=a0+b0;a[n+1]=ae;
//for(int i=1;i<n;i++) a[i+1]=2*a[i]+2*c[i]-a[i-1];
//if(n>0 && fabs(a[n]*2+2*c[n]-a[n-1]-ae)>1e-5) cout<<"err"<<endl;
cout<<a0+b0<<endl;
}
}