|
|
вернуться в форумhelp for Simple CAlculations which is the TIP of the of the {a0, an+1, c1, ... , cn} because my formula is correct but I still get Wrong Answer Re: help for Simple CAlculations > which is the TIP of the of the {a0, an+1, c1, ... , cn} > because my formula is correct but I still get Wrong Answer Maybe your formula is wrong. It happend to me too the first time. Here is the code which solves the problem. It was accepted. for (int k=n;k>=1;k--) { a[k]=a[0]; for (i=k;i>=1;i--) a[k]-=i*2*c[i]; a[k]+=k*a[k+1]; a[k]/=k+1; }; Re: help for Simple CAlculations > which is the TIP of the of the {a0, an+1, c1, ... , cn} > because my formula is correct but I still get Wrong Answer Here you are the program I have sent one more time and it was accepted. #include<stdio.h> #include<string.h> #include<stdlib.h> void main() { // FILE *f=fopen("input.txt","rt"); #define f stdin int n,i; float a[3003],c[3003]; fscanf(f,"%d",&n); memset(a,0,sizeof(a)); memset(c,0,sizeof(c)); fscanf(f,"%f %f",&a[0],&a[n+1]); for (i=1;i<=n;i++) fscanf(f,"%f",&c[i]); fclose(f); for (int k=n;k>=1;k--) { a[k]=a[0]; for (i=k;i>=1;i--) a[k]-=i*2*c[i]; a[k]+=k*a[k+1]; a[k]/=k+1; }; printf("%0.2f",a[1]); } |
|
|