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

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

I was just doing virtual on 1338A - Прибавление степеней.

I wrote the following code: 121160133

and it out puts "63" on this test: N = 5, A = {-9, -2, -2, 7, 5} on both versions of C++17.

The probably problematic part is here:

code

If I output i and ans, ans is changed to 63 at i = 2.

But I thought __lg(0) is -1? Also in custom invocation, the error message never appears, and the code is never terminated by assert(false).

Does anyone have any idea?

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

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

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

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

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

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

OK, I couldn't find any reference about that function, but I was able to look at the definition of it in the source code of stl_algobase.h. It looks like the following image and it apparently says that __lg(0) is undefined.