Masala #G

Xotira 16 MB Vaqt 1000 ms
14

Sonlar va bitlar

Sizga \(n\) soni beriladi. Siz shunday \(a\) sonini topingki, u \(n = a + \text{popcount}(a)\) shartni qanoatlantirsin. Bunda \(\text{popcount}(x) - x\) sonining ikkilik sanoq sistemasida ifodalanishidagi 1 lar sonidir.


Kiruvchi ma'lumotlar:

Yagona qatorda bitta butun son - \(n(1 ≤ n ≤ 10_{18})\) kiritiladi.


Chiquvchi ma'lumotlar:

Shartni qanoatlantiruvchi istalgan butun \(a\) sonini chiqaring. Bunday son mavjud bo‘lmasa -1 chiqaring.


Misollar
# input.txt output.txt
1
4
-1
2
11
9
Izoh:

1-testda, shartni qanoatlantiruvchi \(a\) soni yo‘q ekanligini isbotlash mumkin.
2-testda, \(9_{10}\)\(1001_2\). Ko‘rinib turibdiki, \(\text{popcount}(9)\) = \(2\). \(11 = 9 + 2\). Demak, 9 soni shartni qanoatlantiradi.

Robocontest.uz Copyrighted © 2020-2023 by Robocontest Team

Generated in 18ms