Is there anyone tell what critical in this problem??
Is related with floating point error??
What the the success means?
passed>=height or passed>height
And
Failed means?
passed <= 0 or passed < 0
Sample Input Output plz...
Moderator: Board moderators

2 2 2 20
8 6 5 30
97 56 3 10
56 3 1 5
85 26 19 10
59 17 13 11
97 73 23 17
0 0 0 0failure on day 2
failure on day 3
success on day 2
failure on day 32
failure on day 7
failure on day 6
success on day 2
#include <stdio.h>
#include <iostream>
using namespace std;
int main() {
float h,u,d,f;
do {
int hari=0;
scanf("%f %f %f %f",&h, &u, &d, &f);
if (h>0) {
float cur =0;
float after=0; bool stat = true;
do {
hari ++;
if (cur >= h) stat = false;
after = u + cur;
cur = after - d;
if (cur <0) stat = false;
if (after >h) stat = false;
u = u - (u * f/100);
if (u<=0) stat = false;
//u>=0 && (cur >=0 && cur < h) && after < h)
} while (stat);
if (u <=0 || cur <0) printf("failure on day %d\n",hari);
else if (after >= h) printf("succes on day %d\n",hari);
}
} while (h!=0);
}
dennywithy wrote:why i get wrong output at this test:
Users browsing this forum: No registered users and 0 guests