Rydymth

ShuffleParty

Feb 29th, 2024
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.49 KB | Source Code | 0 0
  1. import java.util.Scanner;
  2. import java.lang.Math;
  3.  
  4. public class A {
  5.   static long getPos(long n)
  6.   {
  7.     // 2^k + x = n
  8.     int ctr = 1;
  9.     while ((long)Math.pow(2, ctr) <= n)
  10.     {
  11.       ctr++;
  12.     }
  13.     return (long)Math.pow(2, ctr - 1);
  14.   }
  15.  
  16.   public static void main(String args[])
  17.   {
  18.     Scanner sc = new Scanner(System.in);
  19.     int n = sc.nextInt();
  20.     for (int i = 0; i < n; i++)
  21.     {
  22.       long inp = sc.nextLong();
  23.       System.out.println(getPos(inp));
  24.     }
  25.   }
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment