.

Special Fruit Tree codechef solution

Special Fruit Tree codechef solution

There exists a unique tree in Rahul’s farm that bears Apples and Bananas as its fruits. This tree bear fruits in accordance with the following rules :

  1. Every fruit has two children.
  2. The first child of Banana is a Banana and the second child is an Apple.
  3. The first child of Apple is an Apple and second child is a Banana.
  4. All the generations of Apples and Bananas start with an Apple.

A visual Representation of Tree is as follows :

         A
     /       \
   A           B 
  / \         / \
A     B     B     A

Given the level and position of a fruit determine if it an Apple or a Banana.

Point to Note: Special Fruit Tree codechef solution

  1. The first child is considered as the left child and second as right.
  2. The level of a fruit in the Special Fruit tree is 1-based.
  3. The position of a fruit in the given level of Special Fruit tree is 1-based, counting from left to right.

Input

Single line of input, two integers Level and Position.

Output

For each pair of inputs , output is a single line containing either “Apple” or “Banana”. Outputs that are case insensitive i.e. “APple” ,”APPLE”,”BaNAna” ,etc are correct too but “Apples”, “Bananas” is not.

Constraints: Special Fruit Tree codechef solution

1 ≤ level ≤ 30

1 ≤ position ≤ 2^( level – 1)

Sample Input 1

3 3

Sample Output 1 Special Fruit Tree codechef solution

Banana

Sample Input 2

2 1

Sample Output 2

Apple

 

error: Content is Protected !!!