UVA- 573 The Snail Solution
#include <stdio.h>
int main()
{
float H, U, D, F;
scanf("%f %f %f %f", &H, &U, &D, &F);
while (H > 0)
{
int Day =0;
float fact = (F*U) / 100.0;
float h = 0.0;
int lim = 0.0;
while ((h < H)&&(h >= lim))
{
h += U;
if (h <= H)
h -= D;
U = U - fact;
if (U < lim)
U = lim;
Day++;
}
printf("%s on day %d\n", (h < lim) ? "failure" : "success", Day);
scanf("%f %f %f %f", &H, &U, &D, &F);
}
return 0;
}
int main()
{
float H, U, D, F;
scanf("%f %f %f %f", &H, &U, &D, &F);
while (H > 0)
{
int Day =0;
float fact = (F*U) / 100.0;
float h = 0.0;
int lim = 0.0;
while ((h < H)&&(h >= lim))
{
h += U;
if (h <= H)
h -= D;
U = U - fact;
if (U < lim)
U = lim;
Day++;
}
printf("%s on day %d\n", (h < lim) ? "failure" : "success", Day);
scanf("%f %f %f %f", &H, &U, &D, &F);
}
return 0;
}
Comments
Post a Comment