CCC '00 J3 - Slot Machines

View as PDF

Submit solution

Time limit:2.0s
Memory limit:16M

Problem type

Canadian Computing Competition: 2000 Stage 1, Junior #3, Senior #1

Martha takes a jar of quarters to the casino with the intention of becoming rich. She plays three machines in turn. Unknown to her, the machines are entirely predictable. Each play costs one quarter. The first machine pays 30 quarters every 35^{th} time it is played; the second machine pays 60 quarters every 100^{th} time it is played; the third pays 9 quarters every 10^{th} time it is played.

Input Specification

Your program should take as input the number of quarters in Martha's jar (there will be at least one and fewer than 1000), and the number of times each machine has been played since it last paid.

Output Specification

Your program should output the number of times Martha plays until she goes broke.

Sample Input


Sample Output

Martha plays 66 times before going broke.


  • 1
     commented on July 16, 2017

    I think my code is good, but the second test run isn't working. My code outputs 38? Does anyone else have a similar problem

    • 1
       commented on July 16, 2017

      You rotate the machine immediately so the 2nd machine is the machine Martha goes to at the start. Instead, you should rotate the machine after the first round so that the 1st machine is the machine Martha goes to at the start.

      • 1
         commented on Sept. 29, 2017

        What do you mean "rotate"?