Is __lg(0) problematic?

Правка en6, от rgnerdplayer, 2021-07-03 11:39:22

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?

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en6 Английский rgnerdplayer 2021-07-03 11:39:22 108
en5 Английский rgnerdplayer 2021-07-03 11:38:01 460
en4 Английский rgnerdplayer 2021-07-03 11:24:37 10 Tiny change: 'ation and try to exit o' -> 'ation and attempted to exit o'
en3 Английский rgnerdplayer 2021-07-03 11:23:35 27 Tiny change: ' -2, 7, 5}\n\nBut I ' -> ' -2, 7, 5} on both versions of C++17.\n\nBut I '
en2 Английский rgnerdplayer 2021-07-03 11:21:40 1006
en1 Английский rgnerdplayer 2021-07-03 11:20:36 1305 Initial revision (published)