forked from sitz/UVa-Online-Judge
-
Notifications
You must be signed in to change notification settings - Fork 1
/
10070.cpp
96 lines (91 loc) · 1.58 KB
/
10070.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#include <bits/stdc++.h>
using namespace std;
bool is_leap(const string &y)
{
if (y.size() < 9)
{
stringstream ss;
ss << y;
int year;
ss >> year;
return year % 400 == 0 || (year % 4 == 0 && year % 100 != 0);
}
else
{
int last_two = int(y[y.size() - 2] - '0') * 10 + int(y[y.size() - 1] - '0');
if (last_two == 0)
{
last_two = int(y[y.size() - 4] - '0') * 10 + int(y[y.size() - 3] - '0');
return last_two % 4 == 0;
}
else
{
return last_two % 4 == 0;
}
}
}
bool is_hulu(const string &y)
{
int sum = 0;
if (y[y.size() - 1] != '5' && y[y.size() - 1] != '0')
{
return false;
}
for (int i = 0, sz = y.size(); i < sz; i++)
{
sum += int(y[i] - '0');
}
return sum % 3 == 0;
}
bool is_bulu(const string &y)
{
if (y[y.size() - 1] != '5' && y[y.size() - 1] != '0')
{
return false;
}
int sum1, sum2;
sum1 = sum2 = 0;
for (int i = 0, sz = y.size(); i < sz; i += 2)
{
sum1 += int(y[i] - '0');
}
for (int i = 1, sz = y.size(); i < sz; i += 2)
{
sum2 += int(y[i] - '0');
}
return (sum1 - sum2) % 11 == 0;
}
int main()
{
string input;
int counter = 0;
bool leap, hulu, bulu;
while (getline(cin, input))
{
leap = is_leap(input);
hulu = is_hulu(input);
bulu = is_bulu(input) && leap;
if (counter > 0)
{
cout << endl;
}
counter++;
if (leap)
{
cout << "This is leap year." << endl;
}
if (hulu)
{
cout << "This is huluculu festival year." << endl;
}
if (bulu)
{
cout << "This is bulukulu festival year." << endl;
}
if (!leap && !hulu && !bulu)
{
cout << "This is an ordinary year." << endl;
}
}
return 0;
}