1 / 3
Oct 2015

Hey,
I'm new here and kinda new to programming so I need some help before I can rely on myself.
I'm getting a wrong answer in this problem: http://www.spoj.com/problems/PRISMSA/7 , though I think that my solution is correct.
Here is my source code:

As I got the answer I hid my source code because it was almost complete and because they say so in this post stuck_out_tongue http://discuss.spoj.com/t/read-this-before-posting/2548

I've done the mathematical calculations for a and h values and then used them to calculate S and it appeared to be right for the example input.
If anyone has got an idea why my solution is considered wrong please help me.
I don't think there is a need to put my calculations here but if that helps in knowing what's wrong I'd do it.
Thanks

  • created

    Oct '15
  • last reply

    Oct '15
  • 2

    replies

  • 1.2k

    views

  • 2

    users

  • 2

    links

take care of the output format. Your code produces only one digit after the decimal point for higher input values. Adding e.g.

cout << fixed;
cout.precision(3);

might help.

Thank you a lot man the solution is accepted! smiley
I thought because they said: "If your result is between (1-10^-2)*expected and (1+10^-2)*expected, it will be evaluated as correct." that it won't matter but it seems it does.
Thanks again smile