Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import java.util.*;
import java.io.*;
public class Main {
final static String FNAME = "A-large"; //input file name
public Scanner in;
public PrintWriter out;
void open() throws IOException {
in = new Scanner( new File( FNAME + ".in" ) ) ;
out = new PrintWriter( new File( FNAME + ".out" ) );
}
void close() throws IOException {
out.close();
}
int h;
int w;
char cur;
void run() throws IOException {
int tn = in.nextInt();
for ( int test = 1; test <= tn; test ++ ) {
int N=in.nextInt();
int K=in.nextInt();
int t=((int)Math.pow(2,N))-1;
int res=K-t;
res=res%(t+1);
String ans="OFF";
if(res==0)
ans="ON";
System.out.println("Case #" + test + ": " + ans );
out.println( "Case #" + test + ": " + ans );
}
}
public static void main( String[] args ) throws IOException {
new Thread() {
public void run() {
try {
Main solution = new Main();
solution.open();
solution.run();
solution.close();
} catch ( Exception e ) {
throw new RuntimeException( e );
}
}
}.start();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment