Problem Statement
We are given a set of events. Each of the events is unique. Some events are long, each of these may take any positive amount of time. Different long events may take different amounts of time. The other events are instant, each of these happens instantly at some moment in time.
We want to arrange the events into a schedule. We do not care about exact times when the events take place, we only consider their relative order. For example, given long events A and B and an instant event C, one of the possible schedules looks as follows:
- Event A starts.
- Event B starts.
- Event B ends and at the same time event C happens.
- Event A ends.
You are given an
Definition
- Class:
- EventOrder
- Method:
- getCount
- Parameters:
- int, int
- Returns:
- int
- Method signature:
- int getCount(int longEvents, int instantEvents)
- (be sure your method is public)
Constraints
- longEvents will be between 0 and 1000, inclusive.
- instantEvents will be between 0 and 1000, inclusive.
- At least one of longEvents and instantEvents will be positive.
Examples
0
2
Returns: 3
If we label the events A and B, then the three schedules are "A before B", "both at the same time", and "A after B".
1
1
Returns: 5
If we label the long event A and the instant event B, then the five schedules are "B before A starts", "B when A starts", "B during A", "B when A ends", and "B after A".
2
0
Returns: 13
There are 6 schedules in which no two endpoints of events coincide, 2 schedules when one event starts when the other one ends, 2 schedules with the same beginning and different end, 2 with same end and different beginning, and 1 when the events start and end at the same time.
0
4
Returns: 75
1000
1000
Returns: 665489683
1
0
Returns: 1
0
1
Returns: 1
2
1
Returns: 101
1
2
Returns: 31
3
0
Returns: 409
0
3
Returns: 13
4
1
Returns: 323093
4
7
Returns: 13989478
7
4
Returns: 417933133
997
998
Returns: 359149531
998
997
Returns: 605235182
857
789
Returns: 726313412
997
1
Returns: 529082900
2
355
Returns: 889723939
254
245
Returns: 229655616
936
909
Returns: 702935821
987
988
Returns: 129627381
956
435
Returns: 664968911
234
986
Returns: 390337642
356
356
Returns: 98103717
1000
0
Returns: 374847625
0
1000
Returns: 629517728
1000
1
Returns: 656944515
1
1000
Returns: 862202137
474
747
Returns: 125016932