#include<iostream> #include<cstdio> #include<cstdlib> #define db(a) cout << #a << " = " << a << endl using namespace std; string linea; int n = 0; bool esbisiesto() { bool fin = false; int num = 0, t = 1; for (int i = 0; i < 4 && !fin; i++) { if (i >= n) { fin = true; continue; } num = t * (linea[n - i - 1] - 48) + num; t *= 10; } //db(num); return (num % 4 == 0 && num % 100 != 0) or (num % 400 == 0); } int main() { bool por3, por5, por11, bisiesto, first = true; while (cin >> linea) { if (!first) puts(""); else first = false; n = linea.size(); bisiesto = esbisiesto(); int suma11 = 0; int suma3 = 0; for (int i = 0; i < n; i++) { suma3 += linea[i] - 48; if (i % 2) suma11 += linea[i] - 48; else suma11 -= linea[i] - 48; } por3 = (suma3 % 3 == 0); por5 = (linea[n - 1] - 48) % 5 == 0; por11 = suma11 % 11 == 0; if (bisiesto) puts("This is leap year."); if (por3 && por5) puts("This is huluculu festival year."); if (por5 && por11 && bisiesto) puts("This is bulukulu festival year."); if (!bisiesto && !(por3 && por5) && !(por5 && por11 && bisiesto)) puts("This is an ordinary year."); } return 0; }
viernes, 23 de diciembre de 2011
10070 - Leap Year or Not Leap Year and …, uva
Suscribirse a:
Enviar comentarios (Atom)
No hay comentarios:
Publicar un comentario