Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class Main {
- static Scanner sc = new Scanner(System.in);
- public static Character findingTheCharacter(int n, int k){
- if(n==1 && k==1)return '0';
- int mid = 1<<(n-1);
- if(k==mid){
- return '1';
- }
- if(k<mid){
- return findingTheCharacter(n-1,k);
- }
- if(findingTheCharacter(n-1,2*mid-k)=='0'){
- return '1';
- }
- else{
- return '0';
- }
- }
- public static void main(String[] args) {
- int n = sc.nextInt();
- int k = sc.nextInt();
- System.out.println(findingTheCharacter(n, k));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment