NinjaTurtles
SRM 567 · 2012-12-13 · by gojira_tc
Problem Statement
You are given
Notes
- floor(X) is equal to the largest integer which is less or equal to X.
Constraints
- P will be between 1 and 1,000,000, inclusive.
- K will be between 4 and 100, inclusive.
5 4 Returns: 6
If the Turtles defeated 6 opponents, three of the four Turtles would eat floor(6 / 4) = 1 pizza each and the fourth one would eat floor(6 / 3) = 2 pizzas, which makes 5 pizzas in total. Note that you always have to return the smallest possible N. For example, in this scenario for N = 7 the Turtles would also eat 5 pizzas, but 7 is not a correct return value, because 6 is less than 7.
1 4 Returns: 3
After a fight with three opponents, only the hungry Turtle would eat a pizza.
13 6 Returns: -1
There is no value of N such that if the Turtles battle N opponents, they eat exactly 13 pizzas for K = 6.
13 17 Returns: 30
For K = 17, after defeating 30 opponents the Turtles will eat 13 pizzas in total.
122 21 Returns: 258
Submissions are judged against all 104 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class NinjaTurtles with a public method int countOpponents(int P, int K) · 104 test cases · 2 s / 256 MB per case