#abc281g. G - Farthest City
G - Farthest City
Score : points
问题描述
给定正整数 和 。
求满足以下条件的简单连通无向图的数量,对模 。
- 对于所有 ,从顶点 到顶点 的最短距离严格小于从顶点 到顶点 的最短距离。
这里,从顶点 到顶点 的最短距离是在一条简单路径中连接顶点 和 的最少边数。
两个图仅当存在两个顶点 和 在其中一个图中通过一条边相连而在另一个图中没有相连时,被认为是不同的。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
You are given positive integers and .
Find the number, modulo , of simple connected undirected graphs with vertices numbered that satisfy the following condition.
- For every , the shortest distance from vertex to vertex is strictly smaller than the shortest distance from vertex to vertex .
Here, the shortest distance from vertex to vertex is the minimum number of edges in a simple path connecting vertices and .
Two graphs are considered different if and only if there are two vertices and that are connected by an edge in exactly one of those graphs.
Constraints
- and are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
4 1000000000
Sample Output 1
8
The following eight graphs satisfy the condition.
Sample Input 2
3 100000000
Sample Output 2
1
Sample Input 3
500 987654321
Sample Output 3
610860515
Be sure to find the number modulo .
update @ 2024/3/10 11:49:01