CODE先做一個大數%的方法
接著依序判斷閏年、huluculu、bulukulu
不過
WA (line:70)答案不正確您的答案為: This is an ordinary year.
正確答案為: This is huluculu festival year.
#include <iostream>
using namespace std;
#define N 100
#define OFFSET 9
#define CARRY 1000000000
class bigNumber
{
public:
bigNumber(string s);
int operator%(int n);
long long num[N];
};
bigNumber::bigNumber(string s)
{
int i, j, k;
for(i=0;i<N;i++)
num[i]=0;
for(i=s.length()-1, j=0, k=1;i>=0;i--, j++)
{
num[j/OFFSET] += (s[i]-'0')*k;
if(k==CARRY/10)
k=1;
else k*=10;
}
}
int bigNumber::operator%(int n)
{
long long temp=0;
for(int i=N-1;i>=0;i--)
temp=(temp*CARRY+this->num[i])%n;
return temp;
}
int main()
{
string s;
bool L, out;
while(cin >> s)
{
bigNumber Y(s);
L=out=0;
if(Y%400==0||(Y%4==0&&Y%100))
{
cout << "This is leap year.\n";
out=L=1;
}
if(Y%15==0)
{
cout << "This is huluculu festival year.\n";
out=1;
}
if(L&&Y%55==0)
{
cout << "This is bulukulu festival year.\n";
out=1;
}
if(!out)
cout << "This is an ordinary year.\n";
cout << endl;
}
return 0;
}