-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDCEPC504.c
More file actions
81 lines (43 loc) · 1.05 KB
/
DCEPC504.c
File metadata and controls
81 lines (43 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/* I found it through recursive function. U can understand this property it is
1. 1st & 2nd child in every generation is male and female respectively
2. odd childs are first child of its parent
3. even childs are second child of its parent
by finding parent gender U can find the child's gender
*/
#include<stdio.h>
char find(int n,long long m)
{
if(m==1)
return 'm';
else if(m==2)
return 'f';
else{
if(m%2==0)
{
if(find(n-1,(m>>1))=='f')
return 'm';
else
return 'f';
}
else{
if(find(n-1,(m>>1)+1)=='f')
return 'f';
else
return 'm';
}
}
}
int main()
{
int t,n;
long long m;
scanf("%d",&t);
while(t--){
scanf("%d%lld",&n,&m);
if(find(n,m)=='m')
printf("Male\n");
else
printf("Female\n");
}
return 0;
}