提交记录 #465
提交时间:2024-12-10 09:42:54
语言:c
状态:Unaccepted
编译情况:编译成功
固定测试点#1:
固定测试点#2:
固定测试点#3:
固定测试点#4:
固定测试点#5:
固定测试点#6:
固定测试点#7:
附加测试点暂不可用
54【日期】车辆限行
#include <stdio.h>
const char outStr[7][15] = {
"Free.",
"3 and 8.",
"4 and 9.",
"5 and 0.",
"1 and 6.",
"2 and 7.",
"Free."
};
int dIM[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int dIMBKS[13] = {0, 365, 334, 306, 275, 245, 214, 184, 153, 122, 92, 61, 31};
int dIMFtS[13] = {0, 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335};
int iLY(int year) {
return (year % 4 == 0 && year % 100 != 0) || year % 400 == 0;
}
#define D_IM(y, m) ((m == 2 && iLY(y)) ? 29 : dIM[m])
#define D_IMBKS(y, m) ((m <= 2 && iLY(y)) ? dIMBKS[m] + 1 : dIMBKS[m])
#define D_IMFtS(y, m) ((m >= 2 && iLY(y)) ? dIMFtS[m] + 1 : dIMFtS[m])
int main() {
int days = 0, sy = 2012, sm = 4, sd = 8, ty, tm, td;
scanf("%d%d%d", &ty, &tm, &td);
if (sy < ty ) {
days += D_IMBKS(sy, sm) - sd + 1;
sy++;sm=1;sd=1;
}
while (sy < ty) {
days += 365 + iLY(sy);
sy++;
}
days += D_IMFtS(ty, tm) + td - D_IMFtS(sy, sm) - sd;
int week = days % 7; days/=91;days%=5;
if (week != 0 && week != 6) {
week = (week - days+ 4) % 5 + 1;
}
puts(outStr[week]);
return 0;
}