#abc211d. D - Number of Shortest paths
D - Number of Shortest paths
Score : points
问题描述
在AtCoder共和国,有编号为至的个城市和编号为至的条道路。
通过第号道路,可以在一小时内从城市到达城市或反之亦然。
请问从城市尽可能早地到达城市有多少种路径?
由于计数结果可能非常巨大,请输出模后的结果。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
The Republic of AtCoder has cities numbered through and roads numbered through .
Using Road , you can travel from City to or vice versa in one hour.
How many paths are there in which you can get from City to City as early as possible?
Since the count can be enormous, print it modulo .
Constraints
- The pairs are distinct.
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer. If it is impossible to get from City to City , print .
Sample Input 1
4 5
2 4
1 2
2 3
1 3
3 4
Sample Output 1
2
The shortest time needed to get from City to City is hours, which is achieved by two paths: and .
Sample Input 2
4 3
1 3
2 3
2 4
Sample Output 2
1
The shortest time needed to get from City to City is hours, which is achieved by one path: .
Sample Input 3
2 0
Sample Output 3
0
It is impossible to get from City to City , in which case you should print .
Sample Input 4
7 8
1 3
1 4
2 3
2 4
2 5
2 6
5 7
6 7
Sample Output 4
4
update @ 2024/3/10 09:25:56