Problem Statement
Definition
- Class:
- MaximalTriangle
- Method:
- howMany
- Parameters:
- int, int
- Returns:
- int
- Method signature:
- int howMany(int n, int z)
- (be sure your method is public)
Constraints
- n will be between 3 and 444, inclusive.
- z will be between 1 and 1,000,000,000 (10^9), inclusive.
Examples
4
1000000000
Returns: 0
There are two ways how to select a diagonal in a square. Each of them produces two triangles of equal size.
5
100
Returns: 5
There are five ways how to select two non-intersecting diagonals in a regular pentagon. Each of them produces an arrangement in which one triangle has a larger area than each of the other two.
6
1000003
Returns: 2
For a regular hexagon, some sets of diagonals produce a good set of triangles, and some do not.
10
1000000000
Returns: 1010
15
1000000000
Returns: 714340
443
999999999
Returns: 293730061
442
999999998
Returns: 504849616
441
999999997
Returns: 737824348
7
100
Returns: 42
8
1
Returns: 0
101
1
Returns: 0
444
1
Returns: 0
400
1000003
Returns: 543714
400
1000000000
Returns: 697280800
428
900000005
Returns: 180276168
400
536870912
Returns: 462616864
119
12
Returns: 4
179
2
Returns: 0
77
1
Returns: 0
362
362362362
Returns: 266860970
277
1000003
Returns: 539042
89
1000000000
Returns: 545362956
414
414414414
Returns: 381243078
444
111
Returns: 0
444
12124142
Returns: 4963244
195
195195159
Returns: 194222559
100
987654321
Returns: 308571232
3
1
Returns: 0
444
1000000000
Returns: 877420096
444
999999777
Returns: 8725155