Village Planning
Time limit3sMemory limit1024 MB
For each N from 2 to M, sum the product of A[f(i,j)] over all labeled simple graphs on N houses, where f counts simple paths and at most K are allowed.
- Level
Hard9 of 10
- Topics
- Graph, Combinatorics, Dynamic programming
- Solved
- No attempts yet
Problem
As the mayor of the RUN town, you are planning to build a new village. The village consists of houses and roads connecting two different houses. No two roads connect the same pair of houses. In other words, the village can be treated as a simple graph, where each house is a vertex and each road is an edge. The village may be disconnected.
You want your village to be as simple as possible. Therefore, for any distinct houses and , there should be at most simple paths from house to house .
Let be the number of houses. The score of the village is , where is the number of simple paths from house to house .
The number of houses is not yet determined, but it is an integer between and . For each from to , calculate the sum of the scores of all possible villages with houses.
Since the answers can be large, output them modulo .
Input
The first line contains two space-separated integers and .
The second line contains space-separated integers .
Output
For each from to , output the sum of the scores of all possible villages with houses, modulo . The answers are separated by a space.