Solution-// UVa - 573 - The Snail#include <cstdio>using namespace std;int main() {int h, u, d, f;
while (scanf("%d %d %d %d", &h, &u, &d, &f), h || u || d || f) {double currentU = u;double distanceMin = u * (f / 100.0);double curreentH = 0;int currentDay = 0;do {currentDay++;currentH += currU;if (currentH > h){printf("success on day ");break;
}currentH -= d;if (currentH < 0){printf("failure on day ");break;}currentU -= distMin;if (currentU < 0)currentU = 0;} while (true);printf("%d\n",currentDay);}return 0;}
Digital Valley provides you solutions to all your problems related to coding, computing and what not, in a user-friendly manner. Mix computing with fun, and 'this' is what you get!
Friday, 17 January 2014
Uva : 573 : The Snail
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment