DMGR's blog

By DMGR, 9 years ago, In English

I was solving this problem from Round 240 Div 2.

415D - Mashmokh and ACM

I wrote this code on Ideone Code Link .However when I submitted it on codeforces I got WA on 4th test case which was "1478 194" with answer "312087753" and my output "285334421". When I gave this input to my ideone code,I got the right answer "312087753". But when I tried it with custom invocation of codeforces ,I got the wrong answer again, "285334421". Is their something different between ideone compilers and codeforces compilers.What can I do get to get correct answer on codeforces?

PS- Ideone code was compiled with C++14 and codeforces with C++11 .Is that the issue somehow?

  • Vote: I like it
  • -11
  • Vote: I do not like it

»
9 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Do not use std::pow when it is not necessary.

AC 10018507

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

    Thanks.It was returning 28 for pow(29,1).

    • »
      »
      »
      9 years ago, # ^ |
        Vote: I like it +6 Vote: I do not like it

      pow() has been misusing its power xP

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

      It's bug with MINGW : LINK:

      • »
        »
        »
        »
        9 years ago, # ^ |
        Rev. 2   Vote: I like it +5 Vote: I do not like it

        It's not a bug.

        double pow (double base, double exponent);

        So for example,
        pow(5.0, 2.0) is evaluated to something like 24.9999...
        When you use an integer to store such value int res = pow(5.0, 2.0);
        The return value is converted to int: (double) 24.9999... = (int) 24.