FReAk's blog

By FReAk, history, 4 weeks ago, In English

Can anybody explain why there is a variation in answer if I change the c++ version ?

problem link : 1228C - Primes and Multiplication

My submission got wrong verdict in testcase 14 using GNU C++17 (64) 116231648

My submission got AC using GNU C++17 116231294

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

4 weeks ago, # |
Rev. 3   Vote: I like it +15 Vote: I do not like it

The issue is with the pow function, the value returned by it can overflow double.

  1. Either typecast the values to long double before passing (AC code), or
  2. Just use powl()

See this for more details.

I am not sure, why it worked for the 32-bit version

32 bit g++ by default does all of its floating-point arithmetic with (80 bit) long double. See this for more info.

4 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by FReAk (previous revision, new revision, compare).