-
Notifications
You must be signed in to change notification settings - Fork 6
/
44_ContinousCards.cpp
70 lines (64 loc) · 1.09 KB
/
44_ContinousCards.cpp
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
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
bool IsContinous(int n, int *num)
{
if (num == NULL || n < 1)
return false;
int number_of_zero = 0;
int number_of_gap = 0;
int num_repeat[14];
for (int i = 0; i < 14; i++)
num_repeat[i] = 0;
for (int i = 0; i < n; i++)
{
num_repeat[num[i]] ++;
if (num_repeat[num[i]] > 1 && num[i] != 0)
return false;
}
number_of_zero = num_repeat[0];
int j = number_of_zero;
for (int i = 0; i < j; i++)
num[i] = 0;
int big, small;
for (int i = 1; i < 14; i++)
{
if (num_repeat[i] != 0)
{
num[j] = i;
j++;
}
}
small = number_of_zero;
big = small + 1;
while (big < n)
{
number_of_gap += num[big] - num[small] - 1;
small = big;
big++;
}
if (number_of_gap > number_of_zero)
return false;
else
return true;
}
int main(void)
{
int n;
cin >> n;
while (n)
{
int *num = new int[n];
for (int i = 0; i < n; i++)
cin >> num[i];
bool TF = IsContinous(n, num);
if (TF)
cout << "So Lucky!" << endl;
else
cout << "Oh My God!" << endl;
cin >> n;
}
return 0;
}