What's wrong with this CODE (FLOW011)

Here is my code: https://ideone.com/C9yphR
The expected output is also produced and the limits of the variables is also satisfied. The output format is also correct. Please help me with the code.
Thanks a lot!

Here-

Input
1
1511
Your Output
3491.8
Expected Output
3491.8 (sorry, you were right)

This question is a bit strange on output terms. AFAIK, it doesnt check for relative error etc. It checks for equality, which it shouldnt (this makes some correct methods to fail).

Your method, by and large, is correct. Look at the code I gave in comment for reference on how to print to get AC, even though you should had gotten AC w/o using that as well.

1 Like

You don’t have to round the ans off. It should be in full form and definetly you will get an AC.

You should use something like this using setprecision() and fixed.

http://www.cplusplus.com/reference/iomanip/setprecision/

i guess a bit of googling would have helped u . and moreover you can go to the all submissions tab and can filter out others submissions and that will help you a lot develop your skills. :slight_smile:
http://www.cplusplus.com/reference/iomanip/setprecision/

Hi,

We are sorry. This problem had issues in the testdata, and has been fixed now. Now any solutions which are within 10^(-2) of the correct answer will be accepted, irrespective of the number of digits printed.

Cheers,
CodeChef

Try to avoid using award point feature. It reduces your karma. Contribute to community and once you get over 15 karma you can upvote like others :slight_smile:

1 Like

I am not able to understand, how to frame the new code! Could you help me out? Thanks!

Why not?

What I feel you should try is, after obtaining the decimal value of money, multiply it with 100, use Math.round() or Math.floor() or Math.ceil (whichever gives AC, problem statement vague in this regard) and then again divide by 100. I think that should easily reduce to 2 digits. (Not much familiar with JAVA, sorry).

Alternatively, you can look at others code under “All Submissions”. Filter out the codes in your languages.

I removed the rounding part and ended up with the following code, yet I get wrong answer!

Okay, I think we need to bring back the rounding part. Sorry for that, I misread the Q.

You can look at these solutions for reference- https://www.codechef.com/viewsolution/14905088 This one converts answer to string, and removes trailing 0s and decimals by reducing string length by 1 incase trailing 0 or trailing “.” is encountered.

1 Like