Problem Type : Ad hoc
#include<stdio.h>
int main()
{
int i,j,k;
double he,in,cd,hac,has,H,U,D,F;
while(scanf("%lf %lf %lf %lf",&H,&U,&D,&F)==4)
{
if(H==0)
break;
he = U*(F/100);
has=0;
hac=0;
cd = U;
for(i=1; ; i++)
{
hac += cd;
if (hac > H)
{
printf("success on day ");
break;
}
hac -= D;
if (hac < 0)
{
printf("failure on day ");
break;
}
cd -= he;
if (cd < 0)
{
cd = 0;
}
}
printf("%d\n",i);
}
}
#include<stdio.h>
int main()
{
int i,j,k;
double he,in,cd,hac,has,H,U,D,F;
while(scanf("%lf %lf %lf %lf",&H,&U,&D,&F)==4)
{
if(H==0)
break;
he = U*(F/100);
has=0;
hac=0;
cd = U;
for(i=1; ; i++)
{
hac += cd;
if (hac > H)
{
printf("success on day ");
break;
}
hac -= D;
if (hac < 0)
{
printf("failure on day ");
break;
}
cd -= he;
if (cd < 0)
{
cd = 0;
}
}
printf("%d\n",i);
}
}
No comments:
Post a Comment