-
Notifications
You must be signed in to change notification settings - Fork 0
/
CHEFADV.java.txt
88 lines (88 loc) · 1.77 KB
/
CHEFADV.java.txt
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
82
83
84
85
86
87
88
import java.io.*;
import java.util.*;
class Main
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int T,N,M,X,Y,f;
T=sc.nextInt();
while(T>0)
{
f=0;
N=sc.nextInt();
M=sc.nextInt();
X=sc.nextInt();
Y=sc.nextInt();
if(N==1 && M==1)
{
System.out.println("Chefirnemo");
T--;
continue;
}
else if(N==1 && M!=1)
{
M=M-1;
if(M%Y==0)
{
System.out.println("Chefirnemo");
}
else
{
System.out.println("Pofik");
}
T--;
continue;
}
else if(N!=1 && M==1)
{
N=N-1;
if(N%X==0)
{
System.out.println("Chefirnemo");
}
else
{
System.out.println("Pofik");
}
T--;
continue;
}
N=N-1;
M=M-1;
if(N%X==0)
{
if(M%Y==0)
{
f=1;
}
else
{
N=N-1;
M=M-1;
if ((N%X==0) && (M%Y==0))
{
f=1;
}
}
}
else{
N=N-1;
M=M-1;
if(N%X==0 && M%Y==0)
{
f=1;
}
}
if(f==1)
{
System.out.println("Chefirnemo");
}
else
{
System.out.println("Pofik");
}
T--;
}
}
}