NOIP2016: palindrome Date

Source: Internet
Author: User
Topic Description in daily life, through the year, month, day these three elements can represent a unique fixed date. Cattle and cattle are used to represent a date in 8 digits, where the first 4 represents the year, the next 2 represents the month, and the last 2 represents the date. Obviously: a date has only one representation method, and two different date representations are not the same. Niuniu that a date is a palindrome, when and only when the 8 digits of this date are palindrome. Now, Niu Niu wants to know how many real-life dates are palindrome, in terms of the two dates that are included between the two dates he specifies. A 8-digit number is palindrome, when and only if it is the same for all I (1 <=i<= 8) from the first number of the left to right and the first number of 9-i (that is, the number one from right to left). For example: • For November 19, 2016, 8 digit 20161119 indicates that it is not a palindrome. • For January 2, 2010, 8 digit 20100102 indicates that it is a palindrome. • For October 2, 2010, 8 digit 20101002 indicates that it is not a palindrome. There are 12 months in each year: of these, 1, 3, 5, 7, 8, 10, December each month 31 days, 4, 6, 9, November each month 30 days, and for February, leap year 29 days, excepting when 28 days. one year is leap years if and only if it satisfies one of the following two situations: 1. This year is 4 integer times, but not 100 integer times; 2. This year is an integer multiple of 400. For example: • The following years are leap year: 2000, 2012, 2016. • The following years are excepting: 1900, 2011, 2014. Input Format: the input includes two lines, each containing a 8-digit number. The first line indicates the specified starting date for the ox. The second line indicates the specified end date of the ox. Ensure that the date_i and all dates are real and that the year part must be 4 digits and the first number is not 0. ensure date1-is not later than Date2. output Format: The output line, containing an integer, indicates how many dates are palindrome between Date1 and Date2. Sample 1 Input: 20110101 20111231 Sample 1 output: 1 Sample 2 Input: 20000101 20101231 Sample 2 output: 2Sample description For example 1, the qualifying date is 20111102. For Sample 2, the qualifying dates are 20011002 and 20100102. "Subtasks" for 60% of the data, satisfies date1 = Date2. -------------------------------------------------------------------------This is a relatively simple problem. But because I wrote the code in a complicated test, the results of the civil test was only 60 points (in fact, the part that can be cheated) later thought, you can not deal with the string itself, we can be a given number of the form of the date, after the implementation of a much simpler.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20-21

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.