Description
Oaiei is idle, and recently he wants to travel around the country. In his country there are N cities, they are numbered from 1 to N. There are roads between some cities, but some are not directly connected with each other. Oaiei lives in the city 1, and he wants to go to city N. Now, he has a question. In k steps, he would like to know there are how many ways from city 1 to city N. You should note that althought there is a road between city A and city B, there is not necessarily a road between city B and city A.
Input
There are multiple tests. For each test, the first line contains three integers N、M and k(2<=N<=100,1<=M<=N*N,1<=k<=10^9), N denotes the number of cities, M denotes the number of roads between the N cities. Following M lines, each line contains two integers A and B, denoting there is a road between city A and city B.
Output
There are how many ways from city 1 to city N. Becase the answer can be very large, you should output the answer MOD 10000.
Sample Input
4 5 9 1 2 2 3 3 4 4 1 1 3 4 5 1 1 2 2 3 3 4 4 1 1 3
Sample Output
3 0
求k秒之后在n的方案数,对于图来说,求方案数等同于进行矩阵乘法,所有直接快速幂即可。
FAQ | About |
Google Group |
Discuss |
Author