Connection Status:
Competition Arena > ToastXRaspberry
Member SRM 503 · 2010-11-01 · by dolphinigle · Greedy, Simple Math, Simulation
Class Name: ToastXRaspberry
Return Type: int
Method Name: apply
Arg Types: (int, int)
Problem Statement

Problem Statement

You have some raspberry jam and a slice of plain toast. You're going to create a slice of breathtaking raspberry toast by applying some of the jam to the toast. Each application will apply L layers of raspberry jam, where L is a positive integer (chosen before the application) and L is not greater than upper_limit. A slice of breathtaking raspberry toast is a slice of plain toast that has had exactly layer_count layers of raspberry jam applied. Return the minimum number of applications required to turn a slice of plain toast into a slice of breathtaking raspberry toast.

Constraints

  • upper_limit will be between 1 and 100, inclusive.
  • layer_count will be between 1 and 1000, inclusive.
Examples
0)
4
13
Returns: 4

One possible way is to apply 4, 4, 3, then 2 layers of jam.

1)
8
5
Returns: 1

A single application is sufficient.

2)
100
1000
Returns: 10
3)
99
1000
Returns: 11
4)
1
1
Returns: 1

Submissions are judged against all 129 archived test cases, of which 5 are shown here. Case numbers match the judge’s.

Coding Area

Language: C++17 · define a public class ToastXRaspberry with a public method int apply(int upper_limit, int layer_count) · 129 test cases · 2 s / 256 MB per case

Submitting as anonymous