若是凉夜已成梦

青春里 总有些事情要努力去做 总有些梦想要拼命去追。


  • 运维

  • 前端

  • 编程

  • 随笔

  • hust-oj

1575: Distinct Subsequences

发表于 2017-10-06   |   分类于 HUSTOJ   |   阅读次数 1,158

题目描述

A subsequence of a given sequence S consists of S with zero or more elements deleted. Formally, a sequence Z = z1z2…zk
is a subsequence of X = x1x2…xm if there exists a strictly increasing sequence < i1, i2,…, ik > of indices of X such that for all j = 1, 2,…, k, we have xij = zj. For example, Z = bcdb is a subsequence of X = abcbdab with corresponding index sequence < 2, 3, 5, 7 >.

Your job is to write a program that counts the number of occurrences of Z in X as a subsequence such that each has a distinct index sequence.

输入

The first line of the input contains an integer N indicating the number of test cases to follow. The first line of each test case contains a string X, composed entirely of lowercase alphabetic characters and having length no greater than 10,000. The second line contains another string Z having length no greater than 100 and also composed of only lowercase alphabetic characters. Be assured that neither Z nor any prefix or suffix of Z will have more than 10100 distinct occurrences in X as a subsequence.

输出

For each test case, output the number of distinct occurrences of Z in X as a subsequence.
Output for each input set must be on a separate line.

样例输入

2
babgbag
bag
rabbbit
rabbit

样例输出

5
3


参考代码

暂无

解析

暂无

hustoj

发表评论 取消回复

电子邮件地址不会被公开。 必填项已用*标注

*
*


hoxis wechat
著作权归作者所有
站点更新说明
  • 文章目录
  • 站点概览
若是凉夜已成梦

若是凉夜已成梦

青春里 总有些事情要努力去做 总有些梦想要拼命去追。

1904 日志
6 分类
12 标签
RSS
weibo github twitter facebook

友情链接

Skip Dreams孤独患者 原站点
© 2017 若是凉夜已成梦
Powered by WordPress | 已运行
Theme By NexT.Mist