Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.lang.Math;
- public class A {
- static long getPos(long n)
- {
- // 2^k + x = n
- int ctr = 1;
- while ((long)Math.pow(2, ctr) <= n)
- {
- ctr++;
- }
- return (long)Math.pow(2, ctr - 1);
- }
- public static void main(String args[])
- {
- Scanner sc = new Scanner(System.in);
- int n = sc.nextInt();
- for (int i = 0; i < n; i++)
- {
- long inp = sc.nextLong();
- System.out.println(getPos(inp));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment