Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <ctype.h>
- #include <string.h>
- #include <math.h>
- int main(){
- int T, x, lowbit, i, ans = 0;
- scanf("%d", &T);
- while(T--){
- scanf("%d", &x);
- lowbit = 0;
- ans = 0;
- if(x == 1){
- puts("3");continue;
- }
- for(i = 0;i < 32;i++){
- if(x & (1 << i)){
- lowbit = i;break;
- }
- }
- ans = 1 << lowbit;
- if(ans == x){
- ans |= 1;
- }
- printf("%d\n", ans);
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment