Statistics

Problem Statement for "LineMST"

Problem Statement

Given are ints N and L.

A complete graph is a graph in which each pair of vertices is connected by exactly one undirected edge.

A graph is called beautiful if:

  • It is a complete graph on N vertices.
  • Each edge has an associated cost, and all these costs are integers between 1 and L, inclusive.
Hence, there are exactly L^(N*(N-1)/2) different beautiful graphs.

The minimum spanning tree (MST) of a beautiful graph is its subgraph with the following properties:

  • The subgraph contains all N vertices.
  • The subgraph is connected. (I.e., it is possible to get from any vertex to any other vertex using only edges that belong to the subgraph.)
  • The total cost of edges in the subgraph is as small as possible.
A single beautiful graph can have multiple MSTs. (Each of these MSTs will contain a different set of edges, but they will have the same total cost.)

An MST is called a line if the degree of each of its vertices is at most 2.

Hibiki likes MSTs. She also likes lines. For each beautiful graph G, let f(G) be the number of its MSTs that are lines. (Note that for some beautiful graphs it may be the case that f(G)=0.)

Let X be the sum of the values f(G) over all beautiful graphs G. Please calculate X for her. As X can be very large, compute and return the value (X modulo 1,000,000,007).

Definition

Class:
LineMST
Method:
count
Parameters:
int, int
Returns:
int
Method signature:
int count(int N, int L)
(be sure your method is public)

Constraints

  • N will be between 2 and 200, inclusive.
  • L will be between 1 and 200, inclusive.

Examples

  1. 3

    2

    Returns: 15

    Beautiful graphs are complete graphs on 3 vertices in which each edge has cost either 1 or 2. There are 8 such graphs. Some of these graphs have more than one MST. For example, the graph in which each edge has cost 1 has three different MSTs. In this case, each of those three MSTs is a line, so we count each of them.

  2. 2

    10

    Returns: 10

    There are 10 beautiful graphs and f(G) is 1 for each of them.

  3. 3

    1

    Returns: 3

    Now there is only one beautiful graph. As we already explained in Example 0, this graph has 3 MSTs and each of those is a line.

  4. 8

    41

    Returns: 655468587

  5. 200

    200

    Returns: 152699064

  6. 200

    1

    Returns: 861239556

  7. 200

    2

    Returns: 681666466

  8. 200

    17

    Returns: 99774264

  9. 200

    100

    Returns: 338549153

  10. 200

    199

    Returns: 823249413

  11. 199

    200

    Returns: 127066309

  12. 198

    200

    Returns: 312928197

  13. 199

    199

    Returns: 230595802

  14. 2

    1

    Returns: 1

  15. 2

    2

    Returns: 2

  16. 2

    100

    Returns: 100

  17. 130

    30

    Returns: 684102113

  18. 12

    63

    Returns: 797018408

  19. 9

    37

    Returns: 117160957

  20. 105

    7

    Returns: 60336279

  21. 137

    83

    Returns: 663692243

  22. 191

    20

    Returns: 766633940

  23. 128

    4

    Returns: 804757365

  24. 161

    58

    Returns: 304141530

  25. 176

    33

    Returns: 914220723

  26. 14

    56

    Returns: 802599361

  27. 71

    84

    Returns: 20099910

  28. 192

    1

    Returns: 194555441

  29. 93

    5

    Returns: 65098639

  30. 187

    90

    Returns: 767367751

  31. 108

    40

    Returns: 172447165

  32. 13

    88

    Returns: 603236712

  33. 115

    68

    Returns: 670925797

  34. 102

    67

    Returns: 347527363

  35. 131

    79

    Returns: 460277023

  36. 195

    34

    Returns: 333395286


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: