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

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

https://codeforces.me/contest/678/submission/128786847

With C++17, passing the an int into a function(lcm) which accepts a long long for some reason does not cast it to a long long but keeps it as an int. Then, unsurprisingly after being multiplied with another large int, it overflows.

On C++14 which I compiled locally initially, the int was implicitly converted to long long as expected and my solution worked.

Does anyone know why this is happening? I played around with gdb and compiling using C++17 and my gdb just went haywire once I entered the lcm function with the long long parameter.

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

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

Update: It turns out in c++17, there is std::lcm (and also std::gcd) which was being called instead of my own functions. The stdlib func returned an int since both params were ints.