#include <stdlib.h> #include <stdio.h> #include <string.h> char LeapYearOrNot(char *year,int Digits){ int Last4Digits = atoi(year+Digits-4); if(Last4Digits%4 == 0 && Last4Digits%100 != 0 || Last4Digits%400 == 0) return 'y'; else return 'n'; } char HuluculuOrNot(char *year,int Digits){ //15的倍數 int i,Sum = 0; for(i=0;i<Digits;i++) Sum += year[i]; if(Sum % 3 == 0 && (year[Digits-1] == '0' || year[Digits-1] == '5')) return 'y'; else return 'n'; } char BulukuluOrNot(char *year,int Digits){ int i,Difference; for(i=0,Difference=0;i<Digits;i++){ if(i % 2 == 0) Difference += year[i]; else Difference -= year[i]; } if(abs(Difference) % 11 == 0 && (year[Digits-1] == '0' || year[Digits-1] == '5')) return 'y'; else return 'n'; } int main(void){ char *year = malloc(sizeof(char)*50); while(~scanf("%s",year)){ char year_flag=0; int Digits = strlen(year); if(LeapYearOrNot(year,Digits) == 'y'){ printf("This is leap year.\n"); year_flag = 1; } if(HuluculuOrNot(year,Digits) == 'y'){ printf("This is huluculu festival year.\n"); year_flag = 1; } if(BulukuluOrNot(year,Digits) == 'y' && LeapYearOrNot(year,Digits) == 'y'){ printf("This is bulukulu festival year.\n"); year_flag = 1; } if(!year_flag) printf("This is an ordinary year.\n"); printf("\n"); } }