Problem Link : http://www.codechef.com/problems/DCE05
Solution :
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
/**
*
* @author XCoder
*/
class Odd {
public static int readIntLine() throws IOException {
return Integer.parseInt(br.readLine());
}
public static long readLongLine() throws IOException {
return Long.parseLong(br.readLine());
}
private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
private static PrintWriter pw = new PrintWriter(System.out);
public static void main(String[] args) throws IOException {
int test = readIntLine();
while (test-- > 0) {
long l = readLongLine();
int count = 0;
while (l > 0) {
l = l >> 1;
count++;
}
count--;
long x = 1 << count;
pw.println(x);
pw.flush();
}
pw.close();
}
}
No comments:
Post a Comment