CCF Python题解(100分)201503-3 节日
a, b, c, y1, y2 = map(int, input().split())
data = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
def day(y1, days=0):
for i in range(1850, y1):
days += 365
if leapyear(i):
days += 1
return days
def leapyear(year):
if year % 400 == 0 or (year % 4 == 0 and year % 100 != 0):
return True
else:
return False
defaultdays = day(y1)
for i in range(y1, y2 + 1):
if leapyear(i):
data[2] = 29
currentday = defaultdays
for j in range(a):
currentday += data[j]
count = (currentday + 2) % 7
if count == 0:
count = 7
if count > c:
date = 7 * b + c - count + 1
else:
date = 7 * (b - 1) + c - count + 1
if date <= data[a]:
if a < 10:
month = "0" + str(a)
else:
month = str(a)
if date < 10:
newdate = "0" + str(date)
else:
newdate = str(date)
print(str(i) + '/' + month + '/' + newdate)
else:
print("none")
defaultdays += 365
if leapyear(i):
defaultdays += 1
data[2] = 28