记录编号 |
567562 |
评测结果 |
AAAAAAAAAA |
题目名称 |
[NOIP 2016PJ]回文日期 |
最终得分 |
100 |
用户昵称 |
EmiliaCR |
是否通过 |
通过 |
代码语言 |
C |
运行时间 |
0.000 s |
提交时间 |
2021-12-02 16:01:52 |
内存使用 |
0.00 MiB |
显示代码纯文本
#include <stdio.h>
int fan(int a) {
int ans;
ans = a / 1000 + a / 100 % 10 * 10 + a / 10 % 10 * 100 + a % 10 * 1000;
return ans;
}
int rn(int year) {
int r = 0;
if (year % 100 == 0) {
if (year % 400 == 0) {
r = 1;
}
else {
r = 0;
}
}
else {
if (year % 4 == 0) {
r = 1;
}
else {
r = 0;
}
}
return r;
}
int rq(int da,int y) {
int m, d, t = 0;
m = da / 100;
d = da % 100;
if (m > 12) {
return t;
}
if (m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12) {
if (d > 31) {
return t;
}
else {
t = 1;
}
}
if (m == 4 || m == 6 || m == 9 || m == 11) {
if (d > 30) {
return t;
}
else {
t = 1;
}
}
if (m == 2 && rn(y) == 1) {
if (d > 29) {
return t;
}
else {
t = 1;
}
}
if (m == 2 && rn(y) == 0) {
if (d > 28) {
return t;
}
else {
t = 1;
}
}
return t;
}
int main() {
freopen("datea.in", "r", stdin);
freopen("datea.out", "w", stdout);
int da1,da2,year1,year2,ans=0;
int md1, md2,mdf1,mdf2;
scanf("%d%d", &da1,&da2);
md1 = da1 % 10000; md2 = da2 % 10000;
year1 = da1 / 10000; year2 = da2 / 10000;
if (da1 == da2) {
if (rq(fan(year1), year1) == 1 && fan(year1) == md1) {
ans++;
}
}
else {
for (int i = year1 + 1; i < year2; i++) {
if (rq(fan(i),i) == 1) {
ans++;
}
}
if (fan(year1) < md1 && rq(fan(year1), year1) == 1 && fan(year1) == md1) {
ans++;
}
if (fan(year2) > md2 && rq(fan(year2), year2) == 1 && fan(year2) == md2) {
ans++;
}
}
printf("%d", ans);
return 0;
}