whats wrong in this logic?

,

#include
#include
using namespace std;

int main(){

int w; float b;

cin>>w>>b;


    if((w>=b)||(w%5!=0)){
        cout<<fixed<<setprecision(2)<<b;
    }
    else {
        b=b-(w+0.5);
        cout<<fixed<<setprecision(2)<<b;
    }


return 0;

}

Seems this logic is of problem ATM.

What if input is:

    30 30.25 ??

Replace:

if((w>=b)||(w%5!=0))

with

if((w+0.5>b)||(w%5!=0))

Reason:

If you test that condition 30 30.25, your code fails to product correct output and result as -0.25 which is WA.

So modify the if condition and check whether, (withdrawal amount + processing fee) < total amount.

Hoe you understood the bug… :slight_smile:

Here is an AC solution by modifying your logic:

http://www.codechef.com/viewsolution/5548083

thanx a lot!!

Most welcome… :slight_smile: