#7206: 請問WA line:70


jimmyee (LEVEL_UP)

學校 : 國立臺灣大學
編號 : 20170
來源 : [140.112.42.92]
最後登入時間 :
2016-03-18 15:33:33
d047. 10070 - Leap Year or Not Leap Year and ... -- UVa10070 | From: [140.112.241.231] | 發表日期 : 2012-11-19 10:37

 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;
}
 
ZeroJudge Forum