#1329: 判斷錯誤了...


a310623195623 (.)

學校 : 臺北市立成功高級中學
編號 : 3215
來源 : [140.113.247.113]
最後登入時間 :
2014-03-10 19:28:18
d047. 10070 - Leap Year or Not Leap Year and ... -- UVa10070 | From: [203.64.138.31] | 發表日期 : 2009-02-06 11:49

#include<iostream>
using namespace std;
int main()
{
    string n;
    while(getline(cin,n))
    {
        int a3=0,a11a=0,a11b=0;
        bool b3=0,b5=0,b11=0,b=0;
        int a4=(int)(n[n.length()-2]-'0')*10+(int)(n[n.length()-1]-'0');
        int a400=(int)(n[n.length()-4]-'0')*10+(int)(n[n.length()-3]-'0');
        for(int i=0;i<n.length();i++)
        {
            switch(n[i])
            {
                case '1':
                    a3+=1;
                    if(i%2)
                    a11a+=1;
                    else
                    a11b+=1;
                    break;
                case '2':
                    a3-=1;
                    if(i%2)
                    a11a+=2;
                    else
                    a11b+=2;
                    break;
                case '3':
                    if(i%2)
                    a11a+=3;
                    else
                    a11b+=3;
                    break;
                case '4':
                    a3+=1;
                    if(i%2)
                    a11a+=4;
                    else
                    a11b+=4;
                    break;
                case '5':
                    a3-=1;
                    if(i%2)
                    a11a+=5;
                    else
                    a11b+=5;
                    break;
                case '6':
                    if(i%2)
                    a11a+=6;
                    else
                    a11b+=6;
                    break;
                case '7':
                    a3+=1;
                    if(i%2)
                    a11a+=7;
                    else
                    a11b+=7;
                    break;
                case '8':
                    a3-=1;
                    if(i%2)
                    a11a+=8;
                    else
                    a11b+=8;
                    break;
                case '9':
                    a4+=1;
                    if(i%2)
                    a11a+=9;
                    else
                    a11b+=9;
                    break;
            }
        }
        if(!(a3%3))
        b3=1;
        if(!(a4%4)&&(a4||!(a400%4)))
        {
            cout << "This is leap year.\n";
            b=1;
        }
        if(!(a4%5))
        b5=1;
        if(!(abs(a11a-a11b)%11))
        b11=1;
        if(b3&&b5)
        {
            cout << "This is huluculu festival year.\n";
            b=1;
        }
        if(b5&&b11)
        {
            cout << "This is bulukulu festival year.\n";
            b=1;
        }
        if(!b)
        cout << "This is an ordinary year.\n";
    }
    return 0;
}

 

第19行說答案是平年,

但是我的答案是bulukulu年...

請問第19題題目是什麼= =""?

 
#1331: Re:判斷錯誤了...


a310623195623 (.)

學校 : 臺北市立成功高級中學
編號 : 3215
來源 : [140.113.247.113]
最後登入時間 :
2014-03-10 19:28:18
d047. 10070 - Leap Year or Not Leap Year and ... -- UVa10070 | From: [203.64.138.31] | 發表日期 : 2009-02-06 11:56

抱歉我知道為什麼了...
因為bulukulu年還必須是閏年= ="
題目沒看好...
 
ZeroJudge Forum