1169: [NOIP2016] 回文日期

文件提交:无需freopen 内存限制:128 MB 时间限制:1.000 S
评测方式:普通裁判 命题人:
提交:1 解决:1

题目描述

在日常生活中,通过年、月、日这三个要素可以表示出一个唯一确定的日期。

牛牛习惯用 lns="http://www.w3.org/1998/Math/MathML">8 位数字表示一个日期,其中,前 lns="http://www.w3.org/1998/Math/MathML">4 位代表年份,接下来 lns="http://www.w3.org/1998/Math/MathML">2 位代表月份,最后 lns="http://www.w3.org/1998/Math/MathML">2 位代表日期。显然:一个日期只有一种表示方法,而两个不同的日期的表 示方法不会相同。

牛牛认为,一个日期是回文的,当且仅当表示这个日期的 lns="http://www.w3.org/1998/Math/MathML">8 位数字是回文的。现在,牛牛想知道:在他指定的两个日期之间包含这两个日期本身),有多少个真实存在的日期是回文的。

一个 lns="http://www.w3.org/1998/Math/MathML">8 位数字是回文的,当且仅当对于所有的 lns="http://www.w3.org/1998/Math/MathML">lns="http://www.w3.org/1998/Math/MathML">18)从左向右数的第 lns="http://www.w3.org/1998/Math/MathML"> 个数字和第 lns="http://www.w3.org/1998/Math/MathML">9 个数字(即从右向左数的第 lns="http://www.w3.org/1998/Math/MathML">

 个数字)是相同的。

例如:

  • 对于 2016 年 11 月 19 日,用 lns="http://www.w3.org/1998/Math/MathML">8 位数字 lns="http://www.w3.org/1998/Math/MathML">20161119 表示,它不是回文的。
  • 对于 2010 年 1 月 2 日,用 lns="http://www.w3.org/1998/Math/MathML">8 位数字 lns="http://www.w3.org/1998/Math/MathML">20100102 表示,它是回文的。
  • 对于 2010 年 10 月 2 日,用 lns="http://www.w3.org/1998/Math/MathML">8 位数字 lns="http://www.w3.org/1998/Math/MathML">20101002 表示,它不是回文的。

每一年中都有 lns="http://www.w3.org/1998/Math/MathML">12 个月份:

其中,lns="http://www.w3.org/1998/Math/MathML">1,3,5,7,8,10,12 月每个月有 lns="http://www.w3.org/1998/Math/MathML">31 天;lns="http://www.w3.org/1998/Math/MathML">4,6,9,11 月每个月有 lns="http://www.w3.org/1998/Math/MathML">30 天;而对于 lns="http://www.w3.org/1998/Math/MathML">2 月,闰年时有 lns="http://www.w3.org/1998/Math/MathML">29 天,平年时有 lns="http://www.w3.org/1998/Math/MathML">28 天。

一个年份是闰年当且仅当它满足下列两种情况其中的一种:

  1. 这个年份是 lns="http://www.w3.org/1998/Math/MathML">4 的整数倍,但不是 lns="http://www.w3.org/1998/Math/MathML">100 的整数倍;
  2. 这个年份是 lns="http://www.w3.org/1998/Math/MathML">400 的整数倍。

例如:

  • 以下几个年份都是闰年:lns="http://www.w3.org/1998/Math/MathML">2000,2012,2016
  • 以下几个年份是平年:lns="http://www.w3.org/1998/Math/MathML">1900,2011,2014

输入

两行,每行包括一个 lns="http://www.w3.org/1998/Math/MathML">8 位数字。

第一行表示牛牛指定的起始日期。

第二行表示牛牛指定的终止日期。

保证 lns="http://www.w3.org/1998/Math/MathML">1 和 lns="http://www.w3.org/1998/Math/MathML">2 都是真实存在的日期,且年份部分一定为 lns="http://www.w3.org/1998/Math/MathML">4 位数字,且首位数字不为 lns="http://www.w3.org/1998/Math/MathML">0

保证 lns="http://www.w3.org/1998/Math/MathML">1 一定不晚于 lns="http://www.w3.org/1998/Math/MathML">2

输出

一个整数,表示在 lns="http://www.w3.org/1998/Math/MathML">1 和 lns="http://www.w3.org/1998/Math/MathML">2 之间,有多少个日期是回文的。

样例输入

20110101
20111231

样例输出

1

提示

【样例说明】

对于样例 1,符合条件的日期是 lns="http://www.w3.org/1998/Math/MathML">20111102

对于样例 2,符合条件的日期是 lns="http://www.w3.org/1998/Math/MathML">20011002 和 lns="http://www.w3.org/1998/Math/MathML">20100102

【子任务】

对于 lns="http://www.w3.org/1998/Math/MathML">60% 的数据,满足 lns="http://www.w3.org/1998/Math/MathML">1=2

来源/分类