Sample 1
Inputcopy | Outputcopy |
---|---|
3 2 5 17 | 1 3 15 |
Note
In the first testcase, the maximum value for which the continuous & operation gives 0 value, is 1.
In the second testcase, the maximum value for which the continuous & operation gives 0 value, is 3. No value greater then 3, say for example 4, will give the & sum 0.
- 5&4≠05&4≠0,
- 5&4&3=05&4&3=0.
Hence, 3 is the answer.
#include<stdio.h>
#include<stdlib.h>
int main()
{
int t;
scanf("%d", &t);
while(t--)
{
int n,a=1;
scanf("%d", &n);
while(a<=n/2)
{
a*=2;
}
printf("%d\n", a-1);
}
return 0;
}