XYZCoder
SRM 700 · 2016-10-02 · by lg5293
Problem Statement
You are going to take part in a popular online programming contest. During the contest the contestants will be split across room rooms, with exactly size contestants in each room. (Hence, there will be exactly room*size contestants.) The rooms will be numbered from 1 to room.
The contest is such that there will be no ties. After the contest, each contestant will have a distinct rank between 1 and room*size, inclusive. (The contestant with rank 1 is the winner.)
A room winner is the contestant with the best (i.e., smallest) rank in their room.
You are interested in the ranks of all room winners. Once the contest finishes, you will write down a sequence of room positive integers. For each i, the i-th element of this sequence will be the rank of the winner of room i.
You are given the
Constraints
- room will be between 1 and 100, inclusive.
- size will be between 1 and 100, inclusive.
2 1 Returns: 2
There are 2 rooms, each with 1 contestant. If contestant in room 1 wins the contest, you will write down the list {1,2}. Otherwise, you will write down the list {2,1}. Note that these are considered to be two distinct sequences.
1 2 Returns: 1
There is 1 room with 2 contestants. Regardless of which of them wins, the winner of the only room will have rank 1, so you will write down the list {1}.
2 2 Returns: 4
Now we have 2 rooms, each with 2 contestants. In this case you will write down one of the following four lists: {1,2}, {2,1}, {1,3}, or {3,1}. Note the following: You will never write down the list {2,3}, because the winner of the entire contest (rank 1) has to be the winner of one of the rooms. You will never write down the list {1,4}, because the contestant with rank 4 cannot be a room winner in this setting.
4 5 Returns: 6840
100 100 Returns: 718243627
Submissions are judged against all 46 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class XYZCoder with a public method int countWays(int room, int size) · 46 test cases · 2 s / 256 MB per case