zoukankan      html  css  js  c++  java
  • 一则新闻引发的思考(20200202千年一遇对称日 厦门可正常办结婚登记)

    第一直觉,有点不信,为啥是千年一遇的对称日,废话不多说,代码来验证!

    month_day = {'01': 31, '02': 28, '03':31, '04':30, '05':31, '06':30, '07':31, '08':31, '09':30, '10':31, '11':30, '12':31}   
    
    all_m_d = []
    for mon, days in month_day.items():
        for day in range(1, days+1):
            temp = str(mon) + '{:0>2}'.format(str(day))
            all_m_d.append(temp)
            
    for i in range(1949, 3000):
        year = str(i)
        if year[::-1] in all_m_d:
            print(year+year[::-1])
        
    

      

     结果如下:  

    
    
    20011002
    20100102
    20111102
    20200202
    20211202
    20300302
    20400402
    20500502
    20600602
    20700702
    20800802
    20900902
    21011012
    21100112
    21111112
    21200212
    21211212
    21300312
    21400412
    21500512
    21600612
    21700712
    21800812
    21900912
    22011022
    22100122
    22111122
    22200222
    22211222
    22300322
    22400422
    22500522
    22600622
    22700722
    22800822
    22900922
    View Code
    
    
    

    观察后发现,千年对称日??明年就有好吧(20211202)!

    再猜测:是不是 两个数字组成的对称日,千年才有一次?

    验证如下:

    month_day = {'01': 31, '02': 28, '03':31, '04':30, '05':31, '06':30, '07':31, '08':31, '09':30, '10':31, '11':30, '12':31}   
    
    all_m_d = []
    for mon, days in month_day.items():
        for day in range(1, days+1):
            temp = str(mon) + '{:0>2}'.format(str(day))
            all_m_d.append(temp)
            
    for i in range(1949, 5000):
        year = str(i)
        if year[::-1] in all_m_d:
            y_m_d = year+year[::-1]
            if len(set(y_m_d)) == 2:
                print(y_m_d)
      
    

     

    结果如下:

    20200202
    21111112
    21211212
    22111122
    22200222
    22211222
    30300303
    31111113
    40400404
    41111114
    2111 - 2020 =‬ 91

    也不是!!这才隔了91年!


    总结:
    面对媒体的言论,要保持理智清醒的头脑!

    谢谢看官,溜了溜了
  • 相关阅读:
    HDU5620 KK's Steel(C++语言版)
    HDU5620 KK's Steel(C语言版)
    大整数分解算法
    大整数分解算法
    HDU1319 POJ1595 UVA406 UVALive5490 ZOJ1312 Prime Cuts【素数筛选+打表】
    HDU1106 排序
    B00004 atoi函数
    B00004 atoi函数
    HDU1262 寻找素数对
    HDU1262 寻找素数对
  • 原文地址:https://www.cnblogs.com/liangmingshen/p/12178189.html
Copyright © 2011-2022 走看看