Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
SOS!大侠帮忙看看为什么WA()#include<stdio.h> #include<math.h> int main() { int i,j,n,k,a[13],tm,t=0; double b[13],ts,r,p,sum1,sum2; while(scanf("%d",&n),n!=-1) { if(t)printf("\n"); for(i=1;i<=n;i++)scanf("%d %lf",&a[i],&b[i]); scanf("%d %lf",&tm,&ts); r=0;sum1=0; for(k=1;k<=n;k++)if(a[k]<=tm)sum1+=b[k]*pow(2,tm-a[k]+1); if(fabs(ts-sum1)<1e-8)r=1; else for(i=1;i<15;i++) { p=pow(0.1,i);sum1=sum2=0; for(k=1;k<=n;k++)if(a[k]<=tm)sum1+=b[k]*pow(1+r,tm-a[k]+1); for(j=1;j<=10;j++) { sum2=0; for(k=1;k<=n;k++)if(a[k]<=tm)sum2+=b[k]*pow(1+r+p*j,tm-a[k]+1); if(sum1-ts<0&&sum2-ts>0){r+=p*(j-1);break;} sum1=sum2; } } t++; printf("Case %d: %0.5lf\n",t,r); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator