Problem 3431 --K steps

3431: K steps

"
Time Limit $1$ 秒/Second(s) Memory Limit $512$ 兆字节/Megabyte(s)
提交总数 $2$ 正确数量 $2$
裁判形式 标准裁判/Standard Judge 我的状态 尚未尝试
难度 分类标签
描述
Here are n beautiful towns and m roads(directional edge). yjx wants to visit these towns for relaxation when he suddenly 
got a question. He wants to know the number of schemes  to walk from town A to town B in exactly k steps.A road can be 
visited more then once. It takes exactly one step to walk from one town to another if they are directly connected by a road.
yjx is very entangled with this matter, please help him.
输入First line is a number T, the number of the cases.
Each case is as follows:
First line includes four number: n, m, k, l which means n(1 <= n <= 100)towns, m(1 <= m<=1000)roads, k(1<=k<=1000)steps,
and l (1<=l<=1000) lines test data.
Then there are m lines, and each line is made up of two number u, v (u != v, 1<= u,v <= n) which means one road from u to v.
Then l lines test data, and each line is made up of two number p, q (so you must help yjx to know the number of the scheme that just walk k steps from town p to town q).
hint: maybe there are more than one road from u to v .
For each test data, output the number of the scheme(the number is big, so you must make the number mod 1991).
2
2 2 1 2
1 2
2 1
1 2
2 1
3 2 2 1
1 2
2 3
1 3
1
1
1

推荐代码 查看3431 所有题解 上传题解视频得图灵币

本题记录 用 户(点击查看用户) 运行号(点击购买题解) 时 间
算法最快[$1 $ms] aoj_judger 613424 2020-09-29 00:15:23
内存最少[$0 $KB] aoj_judger 613413 2020-09-28 23:18:35
第一AC aoj_judger 613413 2020-09-28 23:18:35
第一挑战 aoj_judger 613413 2020-09-28 23:18:35

赛题来源/所属竞赛 N/A

竞赛编号 竞赛名称 竞赛时间 访问比赛