Question
Solution
/* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
// create a buffered reader
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int t = Integer.parseInt(br.readLine());
while (t-- > 0)
{
String[] strs = br.readLine().split(" ");
long a = Long.parseLong(strs[0]);
long b = Long.parseLong(strs[1]);
boolean result = (b & (b - 1)) == 0;
System.out.println((result) ? "Yes" : "No");
}
br.close();
}
}
@anon47473735 use a fast output method… like printwriter. I also committed the same mistake during the contest, but later come to know about it through a post!
/* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
// create a buffered reader
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
int t = Integer.parseInt(br.readLine());
while (t-- > 0)
{
String[] strs = br.readLine().split(" ");
long a = Long.parseLong(strs[0]);
long b = Long.parseLong(strs[1]);
boolean result = (b & (b - 1)) == 0;
bw.write((result) ? "YES" : "NO" + "\n");
}
bw.flush();
}
}
@anon47473735 try bw.println() instead of bw.write(), maybe that could solve your problem, Also you have to append “\n” with both of them in order to get proper result.