using System;
public static class Extensions
{
public static int HighestOneBit(this int number)
{
return (int)Math.Pow(2, Convert.ToString(number, 2).Length - 1);
}
}
public class Test
{
public static uint highestOneBit(uint i)
{
i |= (i >> 1);
i |= (i >> 2);
i |= (i >> 4);
i |= (i >> 8);
return i - (i >> 1);
}
public static void Main()
{
Console.WriteLine();
Console.WriteLine((-1).ToString("X"));
Console.WriteLine((Int32.MinValue).HighestOneBit().ToString("X"));
}
}
dXNpbmcgU3lzdGVtOwoKCXB1YmxpYyBzdGF0aWMgY2xhc3MgRXh0ZW5zaW9ucwogICAgewogICAgICAgIHB1YmxpYyBzdGF0aWMgaW50IEhpZ2hlc3RPbmVCaXQodGhpcyBpbnQgbnVtYmVyKQogICAgICAgIHsKICAgICAgICAgICAgcmV0dXJuIChpbnQpTWF0aC5Qb3coMiwgQ29udmVydC5Ub1N0cmluZyhudW1iZXIsIDIpLkxlbmd0aCAtIDEpOwogICAgICAgIH0KICAgIH0KICAgIAoKcHVibGljIGNsYXNzIFRlc3QKewogICAgcHVibGljIHN0YXRpYyB1aW50IGhpZ2hlc3RPbmVCaXQodWludCBpKSAKICAgIHsKICAgICAgICBpIHw9IChpID4+ICAxKTsKICAgICAgICBpIHw9IChpID4+ICAyKTsKICAgICAgICBpIHw9IChpID4+ICA0KTsKICAgICAgICBpIHw9IChpID4+ICA4KTsKICAgICAgICByZXR1cm4gaSAtIChpID4+IDEpOwogICAgfQoKCXB1YmxpYyBzdGF0aWMgdm9pZCBNYWluKCkKCXsKCQlDb25zb2xlLldyaXRlTGluZSgpOwoJCUNvbnNvbGUuV3JpdGVMaW5lKCgtMSkuVG9TdHJpbmcoIlgiKSk7CgkJQ29uc29sZS5Xcml0ZUxpbmUoKEludDMyLk1pblZhbHVlKS5IaWdoZXN0T25lQml0KCkuVG9TdHJpbmcoIlgiKSk7Cgl9Cn0=