Hihocoder: #1148: February 29, python version __python

Source: Internet
Author: User
The number of leap years to a certain year is actually very simple. Set the year to be calculated as a, and the number of leap years up to a year (including year a) is:
leap years =int (A/4)-int (a/100) +int (a/400)

Here: int is taken as Integer function

#-*-coding:utf-8-*-' @author: liuhuiting date:2016 year August 31 Description: The number of leap years to a certain year is actually very simple. Set the year to be calculated as a, The number of leap years up to a year (including year a) is: number of leap years =int (A/4)-int (a/100) +int (a/400) here: INT for take integer function ' import copy def is_leapyear ': Return (y
    
    Ear%4==0 and Year%100!=0) or (year%400==0) def calculate_year (year,mon,day): sum = YEAR/4-year/100 + year/400 if (is_leapyear) and (Mon<2 or (mon==2 and int (day) <29)): Sum-= 1 return sum def split_da Y (year1,year2): Year1_list = [] Year2_list = [] Temp_list = [] temp_list = Copy.deepcopy (ye
    
    Ar1.split (', ')) temp = Temp_list[0].split () temp.append (int (temp_list[1)) year1_list = copy.deepcopy (temp)
    Temp_list = Copy.deepcopy (Year2.split (', ')) temp = Temp_list[0].split () temp.append (int (temp_list[1)) Year2_list = copy.deepcopy (temp) return year1_list,year2_list if __name__ = = ' __main__ ': month = [' January ' , ' February ', ' March ', ' April ', ' may ', ' June ', ' JUly ', ' August ', ' September ', ' October ', ' November ', ' December '] res = 0 num = Int (raw_input ()) for I in range
        
        (num): year1 = Raw_input () year2 = Raw_input () year1_list,year2_list = Split_day (year1, YEAR2) For j in Range (): if (Year1_list[0]==month[j]): Mon1 = j+1 if (year2
        _LIST[0]==MONTH[J]): Mon2 = j+1 num1 = calculate_year (year1_list[2), Mon1, year1_list[1]) num2 = Calculate_year (year2_list[2], Mon2, year2_list[1]) res = NUM2-NUM1 if (is_leapyear (year1_list[2)
             ) and mon1==2 and Int (year1_list[1]) ==29): res = 1 print ' Case #%d:%d '% (i+1,res)


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.