当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

2429:Word Game

题目描述
      It's a game with two players. Given a dictionary of words, a word S chosen from the dictionary to start with, and a word T also chosen from the dictionary as the winning word, which will be described below, the two players take turns to choose a word from the dictionary, satisfying that the first letter of the chosen word is the same as the last letter of previous word. Each word could be chosen more than once.
      Suppose they play exactly n rounds. At the last round, if the player (the first one if n is odd, the second one otherwise) chooses the winning word T, he wins. To your surprise that, the two players are not so clever that they choose words randomly.
      Here comes the question. How many different ways will the first player win if they play no more than N rounds, among all the possible ways satisfying all the conditions above?
输入解释
      An integer C, indicates the number of test cases.
      Then comes C blocks, formatted like this:
      An integer M, indicates the number of words in the dictionary, M <= 30.
      M string consisting of only lowercase letters, represent the words in the dictionary. The length of each word is no more than 10. There are no duplicated words.
      String S, the word to start with.
      String T, the winning word.
      A positive integer N, indicates the maximum number of rounds to play. N fits in a signed 32-bit integer.
输出解释
      For each test case, print a line with an integer W, indicating how many possible ways the first player wins.
      Output the answer modulo 10001.
输入样例
1
3
abc
cac
cde
abc
cde
3
输出样例
2
来自杭电HDUOJ的附加信息
Recommend lcy

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-2429

最后修改于 2020-10-25T22:53:21+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
5000/1000MS(Java/Others) 32768/32768K(Java/Others)