| ||||||||||
| 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 | |||||||||
出现的问题!,谁能帮忙看看!!!!!!!!!In Reply To:谁能告诉我为什么第一,第二个是正确的,而第三个就错了呢!!!!!!!!!! Posted by:cert at 2007-05-12 15:47:13 #include<stdio.h>
int r;
double v,e,f,b;
double fun1(int x)
{
if(x>=r)
return(1.0/(v-e*(x-r)));
else return (1.0/(v-f*(r-x)));
}
int main()
{
int i,j,k,l,m,n,t,flag,x;
int a[101];
double sum,t1,t2;
while(1)
{
scanf("%d",&n);if(n==0) break;
sum=0.0;
for(i=1;i<=n;i++)
scanf("%d",&a[i]);
scanf("%lf",&b);
scanf("%d%lf%lf%lf",&r,&v,&e,&f);
flag=0;
for(x=0;x<a[1];x++)
{
sum+=fun1(x);
}
//printf("%.4lf\n",sum);
for(j=1;j<n;j++)
{ t1=t2=0.0;
// chang
for(i=0;i<a[j+1]-a[j];i++)
t1+=fun1(i);
t1+=b;
// not chang
for(i=a[j]-flag;i<a[j+1]-flag;i++)
t2+=fun1(i);
//printf("%.4lf %.4lf\n",t1,t2);
if(t1>t2) sum+=t2;
else if(t1<=t2)
{
flag=a[j]; sum+=t1;
}
}
printf("%.4lf\n",sum);
}//for while
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator