Блог пользователя FReAk

Автор FReAk, история, 4 года назад, По-английски

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

  • Проголосовать: нравится
  • -2
  • Проголосовать: не нравится

»
4 года назад, # |
Rev. 3   Проголосовать: нравится +15 Проголосовать: не нравится

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.