/* Compute the day name in a week by dd/mm/yyyy * Zeller Formular * c : century, first 2 bits of year * y : year , last 2 bits of year * m : month , if(m<3) m=m+12, y=y-1 * d : days * return : 1-6 for Mon, Tue, Wed ..., 0 for Sun. */ #include<cstdio> int allow[13]={0,31,28,31,30,31,30,31,31,30,31,30,31}; //only for 2001. typo WA here...WTF int getWeek(int c, int y, int m, int d) { return (y + y/4 + c/4 - 2*c + (26*(m+1))/10 + d - 1)%7; } int main() { int n,m,t; scanf("%d %d",&n,&m); if(m>12 || n<1 || m<1 || n>allow[m]) printf("Impossible\n"); else { if(m<3) t=getWeek(20,00,m+12,n); else t=getWeek(20,01,m,n); if(t>0) printf("%d\n",t); else if(t<0) printf("%d\n",t+7); else printf("7\n"); } return 0; } |