-
Notifications
You must be signed in to change notification settings - Fork 1
/
10070 Leap Year or Not Leap Year and ....cpp-bAqnj8D8.txt
69 lines (69 loc) · 1.68 KB
/
10070 Leap Year or Not Leap Year and ....cpp-bAqnj8D8.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
#include<iostream>
using namespace std;
bool LeapYear(string str)
{
int len = str.length();
int div4 = (str.at(len-2)-48)*10 + (str.at(len-1)-48);
bool div100 = false;
if(str.at(len-1)==48 && str.at(len-2)==48)
div100 = true;
bool div400 = false;
if(div100 == true && ((str.at(len-4)-48)*10 + (str.at(len-3)-48))%4 ==0)
div400 = true;
if ((div4%4 ==0 && div100 == false) || div400 == true)
return true;
else
return false;
}
bool Huluculu(string str)
{
int sum = 0;
int len = str.length();
for(int i=0; i<len; i++)
sum = sum + (str.at(i)-48);
if(sum%3 == 0 && (str.at(len-1)=='0' || str.at(len-1)=='5'))
return true;
else
return false;
}
bool Bulukulu(string str)
{
int len = str.length();
int even=0,odd=0;
for(int i=0;i<len;i+=2)
even = even + (str.at(i)-48);
for(int i=1;i<len;i+=2)
odd = odd + (str.at(i)-48);
if((even-odd)%11 == 0 && (str.at(len-1)=='0' || str.at(len-1)=='5'))
return true;
else
return false;
}
int main()
{
string year;int t=0;
while(cin>>year){
bool leap = LeapYear(year);
bool hul = Huluculu(year);
bool bul = Bulukulu(year);
int p=0;
if(t>0)
cout<<endl;
if(leap == true){
cout<<"This is leap year."<<endl;
p++;
}
if(hul == true){
cout<<"This is huluculu festival year."<<endl;
p++;
}
if(bul == true && leap == true){
cout<<"This is bulukulu festival year."<<endl;
p++;
}
if(p==0)
cout<<"This is an ordinary year."<<endl;
t++;
}
return 0;
}