文章
10
粉丝
253
获赞
8
访问
35.3k
根据天数可以求到月份数,也就是月份从1月开始加,知道大于等于天数就可以,此时就找到了,然后算出是这个月的第几天就行:
record = [0,31,28,31,30,31,30,31,31,30,31,30,31]
def main():
while True:
try:
year,day = map(int,(input().split(" ")))
record[2] = 28
if year%400==0 or (year%4==0 and year%100!=0):
record[2] = 29
he = 0
month = 1
for i in range(1,13):
he = he+record[i]
month = i
if he>= day:
break
day = day+record[month]-he
print("{:d}-{:0>2}-{:0>2}".format(year,month,day))
except:
break
if __name__ == '__main__':
main()
登录后发布评论
暂无评论,来抢沙发