Advertisement
wojiaocbj

E3-F

Mar 19th, 2023
802
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.57 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <ctype.h>
  4. #include <string.h>
  5. #include <math.h>
  6. int main(){
  7.     int T, x, lowbit, i, ans = 0;
  8.     scanf("%d", &T);
  9.     while(T--){
  10.         scanf("%d", &x);
  11.         lowbit = 0;
  12.         ans = 0;
  13.         if(x == 1){
  14.             puts("3");continue;
  15.         }
  16.         for(i = 0;i < 32;i++){
  17.             if(x & (1 << i)){
  18.                 lowbit = i;break;
  19.             }
  20.         }
  21.         ans = 1 << lowbit;
  22.         if(ans == x){
  23.             ans |= 1;
  24.         }
  25.         printf("%d\n", ans);
  26.     }
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement