wewark's blog

By wewark, history, 8 years ago, In English

578C - Слабость и бедность My submission here 19371924 gives WA test 30 and I can't find out why. I am using ternary search and Kadane's algorithm. Help please!

  • Vote: I like it
  • 0
  • Vote: I do not like it

»
8 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

I don't see the reason to write this:

cout << fixed << setprecision(7) << calc(round(b * 1000000)/1000000) << endl;

This would lose accuracy of your answer, right?

The following is correct one.

cout << fixed << setprecision(7) << calc(b) << endl;

Another mistake is here:

while (c - b > 0.0000000001) // 1e-10
{
	/**************/
}

The error on number x will be increased by about n times when calculating weakness. So it should be 1e-12.

BTW, it is better to run a certain number of iteration for binary(ternary) search on float number.

  • »
    »
    8 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    AC finally, You're a life saver!! Thank you :D