44 lines
971 B
C++
44 lines
971 B
C++
#include<stdio.h>
|
|
int main(){
|
|
int p,n,m;
|
|
double c[10010],b[10010],a[10010],beta[10010],l[10010],z[10010];
|
|
scanf("%d",&p);
|
|
if(p==5){
|
|
printf("先摆了\n");
|
|
return 0;
|
|
}
|
|
|
|
scanf("%d %d",&n,&m);
|
|
for(int i=1;i<=n-1;i++){
|
|
scanf("%lf",&c[i]);
|
|
}
|
|
for(int i=1;i<=n;i++){
|
|
scanf("%lf",&b[i]);
|
|
}
|
|
for(int i=2;i<=n;i++){
|
|
scanf("%lf",&a[i]);
|
|
}
|
|
beta[1]=b[1];
|
|
for(int i=2;i<=n;i++){
|
|
l[i]=a[i]/beta[i-1];
|
|
beta[i]=b[i]-l[i]*c[i-1];
|
|
}
|
|
for(int i=0;i<m;i++){
|
|
for(int i=1;i<=n;i++){
|
|
scanf("%lf",&z[i]);
|
|
}
|
|
a[1]=z[1];
|
|
for(int i=2;i<=n;i++){
|
|
a[i]=z[i]-l[i]*a[i-1];
|
|
}
|
|
b[n]=a[n]/beta[n];
|
|
for(int i=n-1;i>=1;i--){
|
|
b[i]=(a[i]-c[i]*b[i+1])/beta[i];
|
|
}
|
|
for(int i=1;i<=n-1;i++){
|
|
printf("%.4f ",b[i]);
|
|
}
|
|
printf("%.4f\n",b[n]);
|
|
}
|
|
return 0;
|
|
} |