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 quarters every
time it is played; the second machine pays
quarters every
time it is played; the third pays
quarters every
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 ), 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
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.
Why do I keep getting 39 for test cases 3 and 4?
edit: nvm i just redid the whole question and got perfect
Does she alternates between each machine or she just plays it all before going broke?
"She plays 3 machines in turn"
In case you don't know what "in turn" means, she plays the 1st machine, then the 2nd, then the 3rd, and then the 1st and so on.
On test cases 2 and 3, I seem to be getting 39. Does anyone know what I might be doing wrong?
SAME BRO
same
Can anyone give a description of the four numbers in the sample input
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
The way you are checking when a machine pays is incorrect. Try checking your logic there.
Thank you! Was able to figure it out with your help.
I don't know why but I get the third case wrong for some reason.
any chance you figured out what that issue was? Im running into the same one
This comment is hidden due to too much negative feedback. Click here to view it.
try importing input from sys.stdin
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
What does TLE mean?
It means time limit exceeded. Your program probably took too long to run.
The status codes are explained at https://dmoj.ca/about/codes/
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.
Your error is when the slots repeat (1st slot 35th time, 2ndd slot 100th time, 3rd slot 10th time)
very wise sir
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
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
...implies your output will be clipped when displayed on the site, specifically to 64 characters.
What am I getting wrong in the questions then?
The judge looks for exact matching output, and so you should remove or comment out input prompts. Follow the output specification.
Okay, thank you. I was doing it to Waterloo's formatting.
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
I feel like my program is good but the last test run is wrong?
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.
What do you mean "rotate"?