## CCC '00 S1 - Slot Machines

View as PDF

Points: 5
Time limit: 1.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 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.

• commented on Dec. 5, 2021, 12:14 a.m. edit 5

what does the first, second, third and fourth line is for? edit: nvm

• commented on Nov. 2, 2021, 12:41 p.m.

I'm not sure if anyone had this problem, but make sure that you output the entire sentence in your output. It is not enough to answer with just a number.

• commented on Oct. 22, 2021, 5:42 p.m.

I am getting incorrect answers even though I am sure my program is correct.

• commented on Oct. 23, 2021, 12:51 a.m.

Are you sure? Check line 29 - https://dmoj.ca/src/3974432 :)

• commented on Nov. 5, 2021, 7:20 p.m.

Thank you so much!! I was so puzzled.

• commented on Sept. 15, 2021, 10:16 p.m.

Sorry this is a silly question: But I don't understand where/how to find the criteria in the test cases. So I get case 1 and 4 right and the others wrong. How do I figure out the other case criteria? Thanks.

• commented on Sept. 9, 2021, 5:44 p.m.

Hay guys, kinda a newbie to this awesome website and can't find a lot of help with my issue I get an Invalid return for some reason, I wanna know what kind of output functions I should use? is it print? or is it sys.stdout.write?

Thank you

• commented on April 27, 2021, 9:56 a.m.

I am getting WA on the last question, can anyone take a look and give me a hint?

• commented on April 27, 2021, 12:29 p.m.

I'm looking at your latest submission - https://dmoj.ca/src/3592245.

When Martha wins on a slot machine, lines 23-29 get skipped, thus not adding to the amount of times that slot machine is played. Code it so even when Martha wins, that slot machine's counter (m1, m2, or m3) still gets added by one.

If you need any more help, consider asking on Slack as you will get better and faster answers.

• commented on April 27, 2021, 6:46 p.m.

Thank you

• commented on April 11, 2021, 1:11 p.m. edit 7

When I use quarters > 0, I get WA 39 on test cases 3 and 4, and when I use quarters >= 0 I get WA 39 on test cases 2 and 3. Any tips would be greatly appreciated!

Edit: Figured it out. For those who are also having this issue, a hint is to check if your loop exits at all the places needed.

• commented on April 8, 2021, 10:23 a.m.

Why am I getting the last case wrong? Any help would be appreciated

• commented on April 8, 2021, 10:55 a.m.

In your latest submission, the bug is in line 15 and 16. The first machine seems to be giving out more quarters than it recieves.

• commented on April 8, 2021, 11:03 a.m.

Oh my god thank you that's such a silly mistake

• commented on Feb. 7, 2021, 3:55 p.m.

PYPY3 failed initializing... Was that a problem with my code or with the judge?

• commented on Feb. 7, 2021, 4:07 p.m.

Memory limit is too low for PYPY3, use Python instead.

• commented on Feb. 5, 2021, 6:09 p.m.

If I understand the question properly, Martha plays on the first machine first, then the second machine, and lastly the third machine and then plays the first machine, right? I'm sorry, I was just slightly confused.

Much appreciated, kresteodymium

• commented on Feb. 21, 2021, 11:40 a.m.

the first number is the number of quarters. the rest are which number she is currently on.

• commented on Jan. 30, 2021, 8:28 p.m.

Martha intend to become rich by playing on slots machine the whole day.

• 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.

• 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

• 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?

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

"She plays 3 machines in turn"

• commented on Oct. 29, 2020, 8:05 a.m.

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.

• 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?

• commented on April 18, 2021, 7:01 p.m.

You need to check whether Martha is broke every time she plays. Note that she plays three times with each iteration of the loop, so a simple while (bal > 0) will not suffice.

If you get WA and have 39 as your output, it's likely that you're not checking often enough. 😉

• commented on March 11, 2020, 8:54 p.m. edited

SAME BRO

• commented on March 11, 2020, 9:34 p.m. edited

same

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

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

• 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

• 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.

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

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

• 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.

• 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

• 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.

• 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

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

What does TLE mean?

• commented on Nov. 2, 2018, 8:10 p.m. edited

It means time limit exceeded. Your program probably took too long to run.

• commented on Oct. 9, 2018, 11:57 a.m. edited

The status codes are explained at https://dmoj.ca/about/codes/

• 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.

• 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)

• commented on Oct. 14, 2018, 9:21 p.m. edited

very wise sir

• 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

• 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

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

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

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

What am I getting wrong in the questions then?

• 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.

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

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

• 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

• commented on Feb. 4, 2018, 6:15 p.m. edited

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

• 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.

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

What do you mean "rotate"?