# -*- coding: utf-8 -*- import sys MAX_SLEEP_TIMES = 1000000 HOUR_TO_MINUTES = 60 DAY_TO_HOURS = 24 DAY_TO_MINUTES = DAY_TO_HOURS * HOUR_TO_MINUTES def main(): argvs = sys.argv argc = len(argvs) if(argc != 5): sys.exit() try: sleep_times = int(argvs[1]) alarm_hour = int(argvs[2]) alarm_minute = int(argvs[3]) snooze_cycle = int(argvs[4]) except: # Failed on converting the parameters to Integer. sys.exit() # Parameter value check. if not (1 <= sleep_times <= MAX_SLEEP_TIMES): sys.exit() if not (0 <= alarm_hour <= DAY_TO_HOURS - 1): sys.exit() if not (0 <= alarm_minute <= HOUR_TO_MINUTES - 1): sys.exit() if not (1 <= snooze_cycle <= DAY_TO_MINUTES): sys.exit() waketime_minute = (alarm_hour * HOUR_TO_MINUTES + alarm_minute + snooze_cycle * (sleep_times - 1)) % DAY_TO_MINUTES print(u'%d'%(waketime_minute/HOUR_TO_MINUTES)) print(u'%d'%(waketime_minute%HOUR_TO_MINUTES)) if __name__ == '__main__': main()