解题思路:
注意事项:
参考代码:
#! /usr/bin/python3 # Copyright(c) 2019 note.jorhelp.cn # Authored by Jorhelp on: 2019年 04月 17日 星期三 14:08:32 CST # @desc: 生日日数 days={'1':31, '2':28, '3':31, '4':30, '5':31, '6':30, '7':31, '8':31, '9':30, '10':31,\ '11':30, '12':31} def run(n): if n%4==0: if n%100==0: if n%400==0: return True else: return True return False while True: try: num=10000 year,month,day=map(int, input().split(" ")) current_year=year if run(year): days['2']=29 #出生年还有多少天 num-= (days[str(month)]-day) for i in range(month+1, 13): num-=days[str(i)] current_year+=1 #去掉整数个年份 while num>365: if run(current_year): num-=366 else: num-=365 current_year+=1 #定位到最后一年 if run(current_year): days['2']=29 else: days['2']=28 ry=1 while num>days[str(ry)]: num-=days[str(ry)] ry+=1 rd=num print(str(current_year)+'-'+str(ry)+'-'+str(rd)) except: break
0.0分
4 人评分