CCC '00 S1 - Slot Machines

View as PDF

Submit solution

Points: 5
Time limit: 1.0s
Memory limit: 16M

Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig
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

48
3
10
4

Sample Output

Martha plays 66 times before going broke.

Comments


  • 2
    calluo  commented on Oct. 4, 2020, 6:05 p.m.

    A common problem that those using a while loop may encounter is that Martha's money goes to zero before she gets paid, even though she's supposed to earn money from the machine. The while loop is exited, and your output is incorrect.


  • 2
    Orion222  commented on March 11, 2020, 8:55 p.m. edit 2

    Why do I keep getting 39 for test cases 3 and 4?

    edit: nvm i just redid the whole question and got perfect


  • 5
    cathysun2004  commented on Jan. 10, 2020, 1:22 a.m. edit 2

    Does she alternates between each machine or she just plays it all before going broke?


    • 0
      Neon  commented on Feb. 8, 2020, 11:39 a.m. edited

      "She plays 3 machines in turn"


  • 1
    Julien  commented on Jan. 9, 2020, 8:54 p.m. edited

    On test cases 2 and 3, I seem to be getting 39. Does anyone know what I might be doing wrong?


  • 3
    bt7274  commented on Nov. 8, 2019, 8:58 p.m. edited

    Can anyone give a description of the four numbers in the sample input


  • 1
    zurtar  commented on April 28, 2019, 11:15 p.m. edit 2

    I am having issues with the 4th test cases I cant seem to figure out what the issue is if anyone has some advice that would be great. Test case #3 is outputting 29


    • 3
      Dingledooper  commented on April 29, 2019, 12:55 a.m. edited

      The way you are checking when a machine pays is incorrect. Try checking your logic there.


      • 3
        zurtar  commented on April 29, 2019, 12:31 p.m. edited

        Thank you! Was able to figure it out with your help.


  • 2
    alirezaazimitabrizi  commented on Feb. 16, 2019, 1:13 p.m. edited

    I don't know why but I get the third case wrong for some reason.


    • 2
      zurtar  commented on April 28, 2019, 10:45 p.m. edited

      any chance you figured out what that issue was? Im running into the same one


  • -6
    Arihan10  commented on Jan. 17, 2019, 12:03 p.m. edited

    This comment is hidden due to too much negative feedback. Click here to view it.


    • 1
      Neon  commented on Feb. 8, 2020, 12:12 p.m. edited

      try importing input from sys.stdin

      from sys import stdin
      
      input = stdin.readline
      
      x = int(input())

    • 0
      magicalsoup  commented on Jan. 17, 2019, 12:55 p.m. edited

      your logic just isn't right, you should debug your code yourself and try for at least a couple of hours before posting a comment


  • -2
    NathanHuang  commented on Oct. 9, 2018, 8:26 a.m. edited

    What does TLE mean?


  • 3
    Lemonsity  commented on Sept. 14, 2018, 10:05 a.m. edit 3

    My program runs fine for the first four question, but on question five, my program returns 5718 times. I know that is probably wrong, given how big the number is. Can anyone help me? https://dmoj.ca/src/1005564 The program isn't that efficient yet, but I just want to get it working for now.


    • 3
      Rimuru  commented on Sept. 14, 2018, 12:20 p.m. edited

      Your error is when the slots repeat (1st slot 35th time, 2ndd slot 100th time, 3rd slot 10th time)


  • 1
    1015449  commented on April 5, 2018, 8:45 a.m. edited

    My code works and I feel like it should be fast enough but the 5th test is still running too slow, any suggestions to make it faster


  • 3
    JJ_G4M3R  commented on Nov. 26, 2017, 6:34 p.m. edit 6

    I keep getting 0 on 2000 questions. Even though I tested my code before I submit, the output starts cutting off every time. Why is this happening?

    Example) This is what my clipped output looks like:

    How many quarters does Martha have in the jar? How many times ha


    • 0
      Xyene  commented on Nov. 26, 2017, 6:43 p.m. edited

      Your output (clipped)

      ...implies your output will be clipped when displayed on the site, specifically to 64 characters.


      • 0
        JJ_G4M3R  commented on Nov. 26, 2017, 6:53 p.m. edited

        What am I getting wrong in the questions then?


        • -2
          aeternalis1  commented on Nov. 26, 2017, 6:57 p.m. edited

          The judge looks for exact matching output, and so you should remove or comment out input prompts. Follow the output specification.


          • 2
            JJ_G4M3R  commented on Nov. 26, 2017, 7:08 p.m. edited

            Okay, thank you. I was doing it to Waterloo's formatting.


  • 1
    CarlZCoc  commented on July 16, 2017, 9:13 p.m. edited

    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
      Dordor1218  commented on Feb. 4, 2018, 6:15 p.m. edited

      I feel like my program is good but the last test run is wrong?


    • 1
      wleung_bvg  commented on July 16, 2017, 9:30 p.m. edited

      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.


      • 2
        nikos  commented on Sept. 29, 2017, 7:21 p.m. edited

        What do you mean "rotate"?