https://www.codechef.com/submit/HS08TEST

https://www.codechef.com/submit/HS08TEST

CodeChef is showing my answer is wrong…
But code is perfect according to me…
Help me…
Here is my C code…

#include<stdio.h>
int main()
{int x;
float y;
scanf("%d%f",&x,&y);
if(x%5==0 && y>(float)x)
printf("%.2f",y-(float)x-.5);
else if(x%5!=0 && y>(float)x)
printf("%.2f",y);
else
printf("%.2f",y);
return 0;
}

Consider the following test case:
0 0.10
5 5.20
In both case your code is genarating negative o/p -0.40 and -0.30 but output will be 0.10 and 5.20.
My solution link:https://www.codechef.com/viewsolution/23517918

1 Like