#21278:  幫忙 debug 謝謝


Easonsfriend (去寫./Problems?ownerid=89827)

學校 : 不指定學校
編號 : 89827
來源 : [111.240.110.92]
最後登入時間 :
2024-11-20 15:11:09
d047. 10070 - Leap Year or Not Leap Year and ... -- UVa10070 | From: [106.105.188.90] | 發表日期 : 2020-05-10 23:39

#include <iostream>

using namespace std;

   

bool four(string s){

    return (s[s.size()-1] - '0' + (s[s.size()-2] - '0') * 10)%4==0;

}

bool hundred(string s){

    return s[s.size()-1]=='0' and s[s.size()-2]=='0';

}

bool five(string s){

    return s[s.size()-1]=='0' or s[s.size()-1]=='5';

}

bool three(string s){

    int sum=0;

    for(int i=0;i<s.size();i++)sum+=s[i]-'0';

    return sum%3==0;

}

bool eleven(string s){

    int even=0,odd=0;

    for(int i=0;i<s.size();i+=2)even+=s[i]-'0';

    for(int i=1;i<s.size();i+=2)odd+=s[i]-'0';

    return abs(odd-even)%11==0;

}

bool leap(string s){

    if(four(s) and hundred(s))return true;

    if(hundred(s))return false;

    return four(s);

}

int main() {

    string s;

    while(cin>>s){

        bool flag=false;

        if(leap(s)){

            cout<<"This is leap year.\n";

            flag=true;

        }

        if(three(s) and five(s)){

            cout<<"This is huluculu festival year.\n";

            flag=true;

        }

        if(leap(s) and five(s) and eleven(s)){

            cout<<"This is bulukulu festival year.\n";

            flag=true;

        }

        if(!flag)cout<<"This is an ordinary year.\n";

        cout<<"\n";

    }

    return 0;

 

}

 

 
ZeroJudge Forum