-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgameofpiles2.cpp
More file actions
89 lines (89 loc) · 1.85 KB
/
gameofpiles2.cpp
File metadata and controls
89 lines (89 loc) · 1.85 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
82
83
84
85
86
87
88
89
#include <bits/stdc++.h>
#define ln long long
using namespace std;
int main()
{
// your code goes here
ln num, num1, k;
cin >> num;
while (num--)
{
cin >> num1;
ln str[num1];
ln oddc = 0, twop = 0, onep = 0, sump = 0, p = 0;
for (k = 0; k < num1; k++)
{
cin >> str[k];
if (str[k] == 1)
onep++;
else
{
if (str[k] == 2)
{
twop++;
}
sump += str[k];
p++;
if (str[k] % 2)
oddc++;
}
}
if (onep == 1)
{
if (!(oddc % 2))
{
cout << "chef"
<< "\n";
continue;
}
if (twop == 0)
{
cout << "chefina"
<< "\n";
continue;
}
sump -= 2;
p--;
if ((sump - p) % 2)
{
cout << "chefina"
<< "\n";
continue;
}
else
{
cout << "chef"
<< "\n";
continue;
}
}
else if (onep > 1)
{
if ((sump - p) % 2)
{
cout << "chef"
<< "\n";
continue;
}
else
{
cout << "chefina"
<< "\n";
continue;
}
}
if (oddc % 2)
{
cout << "chef"
<< "\n";
continue;
}
else
{
cout << "chefina"
<< "\n";
continue;
}
}
return 0;
}