Submit | All submissions | Best solutions | Back to list |
DCEPC504 - The Indian Connection |
Rajesh Kuthrapali has a weird family structure. Every male member gives birth to a male child first and then a female child whereas every female member gives birth to a female child first and then to a male child. Rajesh analyses this pattern and wants to know what will be the Kth child in his Nth generation. Help him.
Note:
- Every member has exactly 2 children.
- The generation starts with a male member (Rajesh).
- In the figure given below:
M ------------ 1st generation / \ / \ / \ M F ------- 2nd generation / \ / \ M F F M | 3rd child of 3rd generation
Input
First line specifies T, the number of test cases.
Next T lines each gives 2 numbers, N and K.
Output
Output 1 line for each test case giving the gender of the Kth child in in Nth generation.
Print “Male” for male “Female” for female (quotes only for clarification).
Constraints
1 ≤ T ≤ 100
1 ≤ N ≤ 10000
1 ≤ K ≤ min(1015, 2(n-1))
Example
Input: 4 1 1 2 1 2 2 4 5 Output: Male Male Female Female
Added by: | dce coders |
Date: | 2012-04-18 |
Time limit: | 1.726s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | ASM32-GCC MAWK BC C-CLANG C NCSHARP C++ 4.3.2 CPP CPP14 CPP14-CLANG COBOL COFFEE D-CLANG D-DMD DART ELIXIR FANTOM FORTH GOSU GRV JAVA JS-MONKEY JULIA KTLN NIM NODEJS OBJC OBJC-CLANG OCT PICO PROLOG PYPY PYPY3 PY_NBC R RACKET RUST CHICKEN SQLITE SWIFT UNLAMBDA VB.NET |
Resource: | Own Problem |
hide comments
|
||||||||||||
2013-04-22 15:36:54 D Pratap
NZEC in java ??? Any Idea [ed] ok did it in c++ Last edit: 2013-04-22 16:14:42 |
||||||||||||
2013-04-12 15:35:21 ওয়াসী (Wasi)
Piece of cake when you know the trick! Nice problem indeed ;) |
||||||||||||
2013-04-05 14:35:11 NodaR M JarraR
writing MALE & FEMALE instead of Male & Female costed me three wrong answers!! :( |
||||||||||||
2013-03-23 16:44:03 Eduardo Nunes
nice pattern, indeed... :-D wrong log of powers of 2 cost me 3 WA :P |
||||||||||||
2013-03-23 00:09:47 [Lakshman]
Good one.... |
||||||||||||
2013-02-20 18:24:14 kaun
How male can give birth.......? |
||||||||||||
2013-01-13 14:19:06 god_father
good question... |
||||||||||||
2013-01-09 10:10:49 malioboro
very nice problem, teach me how to implementation the idea... |
||||||||||||
2012-12-30 05:36:30 shreyas
Silly mistake, but yeah problem solved. Dont forget the decrement. |