#include <iostream>
#include <memory.h>
using namespace std;
//floyd算法
int road[102][102];
int result[102][102];
int main()
{
int n,m,l;
int x,y;
int q;
int A,B;
cin >> n >> m >> l;
memset(road,0,sizeof(road));
while(m--)
{
cin >> x >> y;
road[x][y] = 1;
}
//int q;
cin >> q;
while(q--)
{
cin >> A >> B;
memset(result,0,sizeof(result));
result[0][A] = 1;
for(int i = 1;i <= l;i++)
for(int j = 1;j <= n;j++)
for(int k = 1;k <= n;k++)
{
if(road[j][k] == 1)
result[i][k] += result[i - 1][j];
}
cout << result[l][B] << endl;
}
return 0;
}
sicily 1211.商人的宣传
最新推荐文章于 2018-01-23 20:17:19 发布