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

Автор avi_9314, история, 5 лет назад, По-английски

here are some solutions to the problem B of yesterday educational round

approach 1 : find the nearest power of 2

simple implementation : 101610177

using builtin function : 101611194 101612390

using log function : 101611253

approach 2: alternate 1 at even and odd position ( rest elements = a[i]) and compute the sum 2* | a[i] -b[i]| for two different array and print the one with less sum

simple implementation : 101610719

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

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

Can you share me the proof of the second approach? Seems kind of counter-intuitive to me.

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

Another Approach

I thought it'll fail the system testing, but it didn't, so here you go :)