Topic links: at The Chosen One
The meaning of problems
\ (T \) set of sample, given each an integer \ (n-(2 \ n-Le \ Le 10 ^ {50}) \) , find no greater than \ (n-\) maximum \ (2 \) the integer power.
answer
Precision Operational
Java BigInteger
The bitLength()
method digits in a binary representation of large numbers can be calculated directly.
More about Java BigInteger
the operations, refer to my other article the basic usage of computing large numbers of Java BigInteger
import java.util.Scanner;
import java.math.BigInteger;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int t = in.nextInt();
while (t-->0){
BigInteger n = in.nextBigInteger();
BigInteger ans = new BigInteger("2");
System.out.println(ans = ans.pow(n.bitLength() - 1));
}
}
}