#abc204c. C - Tour
C - Tour
Score : points
问题陈述
在AtCoder共和国中,有个城市,编号从1到,以及条道路,编号从1到。
第条道路从城市通向城市,但你不能通过它从城市到达城市。
Puma正在计划她的旅程,她将从某个城市出发,沿着零条或多条道路行进,并最终抵达某个城市。
Puma的旅程可能有多少对起始城市和目的地城市组合?我们需区分具有相同城市集合但顺序不同的对。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
The republic of AtCoder has cities numbered through and roads numbered through .
Road leads from City to City , but you cannot use it to get from City to City .
Puma is planning her journey where she starts at some city, travels along zero or more roads, and finishes at some city.
How many pairs of cities can be the origin and destination of Puma's journey? We distinguish pairs with the same set of cities in different orders.
Constraints
- are distinct.
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
3 3
1 2
2 3
3 2
Sample Output 1
7
We have seven pairs of cities that can be the origin and destination: .
Sample Input 2
3 0
Sample Output 2
3
We have three pairs of cities that can be the origin and destination: .
Sample Input 3
4 4
1 2
2 3
3 4
4 1
Sample Output 3
16
Every pair of cities can be the origin and destination.
update @ 2024/3/10 09:17:13