Friday, April 24, 2015

UVa - 10070 - Leap Year or Not Leap Year

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int main(){
    char years[10000];
    int mod_4, mod_15, mod_55, mod_100, mod_400, space = 0;
    freopen("in.txt", "r", stdin);
    while(scanf("%s", years) == 1){
        mod_4 = mod_15 = mod_55 = mod_100 = mod_400 = 0;
        int l = strlen(years), b = 0, h = 0, bl = 0;
        for(int i = 0; i < l; i++){
            mod_4 = ((mod_4*10) + (years[i]-48)) % 4;
            mod_15 = ((mod_15*10) + (years[i]-48)) % 15;
            mod_55 = ((mod_55*10) + (years[i]-48)) % 55;
            mod_100 = ((mod_100*10) + (years[i]-48)) % 100;
            mod_400 = ((mod_400*10) + (years[i]-48)) % 400;
        }
        if(space != 0)cout << endl;
        if((mod_4 == 0 && mod_100 != 0) || mod_400 == 0){
            puts("This is leap year.");
            b = 1;
        }
        if(mod_15 == 0){
            puts("This is huluculu festival year.");
            h = 1;
        }
        if(mod_55 == 0 && b){
            puts("This is bulukulu festival year.");
            bl = 1;
        }
        if(!h && !b && !bl)puts("This is an ordinary year.");
        space = 1;
    }
    return 0;
}

No comments:

Post a Comment