import sys
round_end = {
1: (24, 23, 59),
2: (25, 23, 59),
3: (26, 23, 59),
4: (27, 23, 59),
5: (29, 23, 59),
}
def to_minutes(d, h, m):
return d * 1440 + h * 60 + m
for line in sys.stdin:
line = line.strip()
if not line:
continue
x, d, h, m = map(int, line.split())
ed, eh, em = round_end[x]
remaining = to_minutes(ed, eh, em) - to_minutes(d, h, m) + 1
if x == 5 and (d<29 or h<2):
remaining -= 60
print(remaining)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | import sys round_end = { 1: (24, 23, 59), 2: (25, 23, 59), 3: (26, 23, 59), 4: (27, 23, 59), 5: (29, 23, 59), } def to_minutes(d, h, m): return d * 1440 + h * 60 + m for line in sys.stdin: line = line.strip() if not line: continue x, d, h, m = map(int, line.split()) ed, eh, em = round_end[x] remaining = to_minutes(ed, eh, em) - to_minutes(d, h, m) + 1 if x == 5 and (d<29 or h<2): remaining -= 60 print(remaining) |
English