## 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 June 21, 2022, 8:19 p.m. edited

I have tried solving the problem in two different ways . . . the first time, I got the fifth test case wrong, and the second time, I got the second test case wrong. Can someone help me and see what is wrong with my program? https://dmoj.ca/src/4646092

• commented on June 25, 2022, 6:48 p.m.

Look carefully at the if statements you use to determine which machine is in play.

• commented on April 29, 2022, 7:44 a.m.

I'm really confused now . My code seems to be fine I tested it 1000 time with different conditions . I was checking every step of the way with the debugger .Everything seems to be fine , but when I submit it , I'm getting error on test 5 !?!?? I'm running out of ideas . Please HELP!!!

• commented on March 10, 2022, 5:34 p.m.

all of Martha's life savings are in quarters and now she spent them all...

• commented on June 21, 2022, 8:18 p.m.

The maximum number of quarters Martha can spend is 999, and 999*25 = 24975. So the most Martha is spending is \$249.75. A lot, but doesn't seem like a person's life savings.

• commented on March 10, 2022, 3:27 p.m. edited

When testing with the sample input/output, this passes all tests, but returns 67 when I test the sample input on my own computer, and this returns the correct 66 when run on my own computer, but fails all tests when I submit it. Why is this? It works but I don't know why.

EDIT: Problem was using >= 0 instead of > 0

• commented on Dec. 9, 2021, 9:45 p.m.

What if she wins and earns more money?

• commented on March 6, 2022, 10:45 a.m.

Rule of las Vegas. The house always wins (unless you know when to quit)

• commented on Dec. 10, 2021, 8:39 a.m.

Then she uses the earned money on the machines.

• 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 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 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 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 Oct. 9, 2018, 8:26 a.m. edited

What does TLE mean?

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