HDU1408看看哪里有错误!
http://acm.hdu.edu.cn/showproblem.php?pid=1408#include<stdio.h>intmain(){doublev,d,i,...
http://acm.hdu.edu.cn/showproblem.php?pid=1408
#include<stdio.h>
int main()
{
double v,d,i,t;
while(scanf("%lf %lf",&v,&d)!=EOF&&v>d&&d>0&&v<5000)
{
t=0;
for(i=1;;i++)
{
if(v>i*d)
{
v=v-i*1.0*d;
t+=i+1;
}
else
{
t+=v*1.0/d;
break;
}
}
printf("%.0lf\n",t);
}
return 0;
} 展开
#include<stdio.h>
int main()
{
double v,d,i,t;
while(scanf("%lf %lf",&v,&d)!=EOF&&v>d&&d>0&&v<5000)
{
t=0;
for(i=1;;i++)
{
if(v>i*d)
{
v=v-i*1.0*d;
t+=i+1;
}
else
{
t+=v*1.0/d;
break;
}
}
printf("%.0lf\n",t);
}
return 0;
} 展开
1个回答
展开全部
// 我的液携解法
#include <stdio.h>
int main()
{
float VUL, D;
int i = 1, t = 0, s = 0, time = 1;
scanf ("%f %f", &VUL, &D);
s = t = D;
while ( (VUL > 0 && VUL < 5000) && (D > 0 && D < VUL) )
{
while ( s < VUL )
{
D += t;
s += D;
time++;
}
break;
}
printf ("激颤%d\明埋败n", (int)VUL + time - 1);
return 0;
}
#include <stdio.h>
int main()
{
float VUL, D;
int i = 1, t = 0, s = 0, time = 1;
scanf ("%f %f", &VUL, &D);
s = t = D;
while ( (VUL > 0 && VUL < 5000) && (D > 0 && D < VUL) )
{
while ( s < VUL )
{
D += t;
s += D;
time++;
}
break;
}
printf ("激颤%d\明埋败n", (int)VUL + time - 1);
return 0;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询