-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathuva-10070.c
More file actions
165 lines (123 loc) · 2.88 KB
/
uva-10070.c
File metadata and controls
165 lines (123 loc) · 2.88 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
char year[100000];
int Length;
int divisible_by_3();
int divisible_by_4();
int divisible_by_5();
int divisible_by_11();
int divisible_by_15();
int divisible_by_55();
int divisible_by_100();
int divisible_by_400();
int main()
{
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
int ordinary, leap, i = 1;
while (scanf("%s", year) != EOF) {
Length = strlen(year);
ordinary = 1;
leap = 0;
if (i > 1) {
printf("\n");
}
if (divisible_by_400() || divisible_by_4() && !divisible_by_100()) {
printf("This is leap year.\n");
ordinary = 0;
leap = 1;
}
if (divisible_by_15()) {
printf("This is huluculu festival year.\n");
ordinary = 0;
}
if (leap && divisible_by_55()) {
printf("This is bulukulu festival year.\n");
ordinary = 0;
}
if (ordinary) {
printf("This is an ordinary year.\n");
}
i++;
}
return 0;
}
int divisible_by_3()
{
int sum = 0, result = 0, i;
for (i = 0; i < Length; i++) {
sum += year[i];
}
if (sum % 3 == 0) {
result = 1;
}
return result;
}
int divisible_by_4()
{
int sum, result = 0;
sum = ((year[Length - 2] - 48) * 10) + (year[Length - 1] - 48);
if (sum % 4 == 0) {
result = 1;
}
return result;
}
int divisible_by_5()
{
int result = 0;
if (year[Length - 1] == '0' || year[Length - 1] == '5') {
result = 1;
}
return result;
}
int divisible_by_11()
{
int odd_sum = 0, even_sum = 0, sum, i, result = 0;
for (i = 0; i < Length; i++) {
if ((i + 1) % 2 == 1) {
odd_sum += (int) year[i] - 48;
}
else {
even_sum += (int) year[i] - 48;
}
}
sum = abs(odd_sum - even_sum);
if (sum % 11 == 0) {
result = 1;
}
return result;
}
int divisible_by_15()
{
int result = 0;
if (divisible_by_3() == 1 && divisible_by_5() == 1) {
result = 1;
}
return result;
}
int divisible_by_55()
{
int result = 0;
if (divisible_by_5() == 1 && divisible_by_11() == 1) {
result = 1;
}
return result;
}
int divisible_by_100()
{
int result = 0;
if (year[Length - 2] == '0' && year[Length - 1] == '0') {
result = 1;
}
return result;
}
int divisible_by_400()
{
int sum, result = 0;
sum = ((year[Length - 4] - 48) * 1000) + ((year[Length - 3] - 48) * 100) + ((year[Length - 2] - 48) * 10) + (year[Length - 1] - 48);
if (sum % 400 == 0) {
result = 1;
}
return result;
}