ECOO '21 P1 - Many Messages

View as PDF

Submit solution


Points: 3 (partial)
Time limit: 2.0s
Memory limit: 256M

Author:
Problem type

Theodore likes to keep in touch with his friends at all times, even when he does homework. Unfortunately, sending and receiving a lot of messages from his friends has caused him to be distracted from doing his very important math homework.

To remedy this issue, Theodore has decided to only check his messages at set intervals of time, starting at some minute. For example, starting at minute 1, Theodore might decide that he wants to check his messages every 30 minutes. Given this set interval the first time he checks his messages will be at minute 31. While studying, Theodore only accounts for the minutes he spends on his homework, disregarding the typical clock format of telling time. Theodore starts his homework at a certain time and decides to check his messages three times, separated by an interval.

Larry sends Theodore a message some time later. Given the interval Theodore uses to checks his messages, when will he read Larry's message?

Input Specification

The first line of input will consist of a single integer, the minute that Theodore starts doing his homework at.

The next line of input will consist of a single integer, the interval that Theodore wants to check his messages at.

The last line of input will consist of a single integer, the minute when Larry sent Theodore a message.

All integers in the input will be between 1 and 100.

For 30\% of the points, Larry will always send his message after Theodore last checked his phone.

Output Specification

Output the first time when Theodore will see Larry's message. If Larry's message is sent after the last time Theodore checks his phone, output Who knows....

Sample Input 1

1
30
91

Sample Output 1

91

Explanation for Sample Output 1

The first time Theodore decides to check his messages is exactly 30 minutes after minute 1, 30 + 1 = 31.

The second time Theodore checks his messages is 30 minutes after the first time, 31 + 30 = 61.

The third time Theodore checks his messages is 30 minutes after the second time, 61 + 30 = 91.

Larry sends his message just as Theo checks his messages for the last time at 91 minutes.

Sample Input 2

5
19
4

Sample Output 2

24

Explanation for Sample Output 2

Theodore will see Larry's message the first time he checks them, at 5 + 19 = 24 minutes.

Sample Input 3

2
10
99

Sample Output 3

Who knows...

Comments


  • 1
    19oliverabbott  commented on Dec. 12, 2023, 8:47 a.m.

    this works with all the test data but not the solution data for some reason? any ideas

    gets inputs

    start = int(input()) check = int(input()) sends = int(input()) done = False

    time = start + check

    if time >= sends: print(time) done = True

    time = time + check if time >= sends and done == False: print(time) done = True

    time = time + check if time >= sends and done == False: print(time) done = True

    if done == False: print("Who Knows... ")


  • 0
    darthvader2021  commented on Nov. 9, 2023, 9:20 p.m.

    Hi, I think the condition is that he checks only 3 times. so any message after the 3rd time is outputted as "who know ..."


  • 1
    fawkeskc  commented on Oct. 4, 2022, 4:50 a.m.

    Anyone having trouble getting this to work? I can only get 30 points and can't figure out what I'm missing.