Chef's best friend Jerry gives Chef a string A and wants to know the number of string A that can be obtained from another string BA is made up of unique characters and every character in B can also be found in A. Chef is only allowed to remove string A from string B when it appears as a substring in string B. After one removal, the gap created will be closed and Chef can repeat the process.

Chef wants you to help Jerry to find the answer.

Input

The first line of the input contains T, the number of test cases.

The first line of each test case contains the string A.

The second line of each test case contains the string B.

Note: Please trim trailing whitespaces

Output

For each test case, output a single line consisting of the number of string A that can be obtained from string B as described.

Constraints

  • 1 ≤ T ≤ 20
  • 1 ≤ |A| ≤ 26
  • A is made up of uppercase alphabet only
  • A does not have repeated characters
  • 1 ≤ |B| ≤ 3×105
  • B only contains characters present in A

Example

Input:
2
TIGER
GTIGETIGERRERTIGTTIGERIGERER
HELO
HELHELLOO Output:
5
0

Explanation

Test case 1: 5 TIGERs can be obtained from code B as follows:
GTIGETIGERRERTIGTTIGERIGERER
GTIGETIGERRERTIGTIGERER
GTIGERERTIGTIGERER
GTIGERERTIGER
GTIGERER
GER

主要是运用 string及其使用 的一道题

 # include <bits/stdc++.h>
using namespace std;
int main ()
{
int T; cin>>T;
while(T--)
{
int sum = ;
string a; cin>>a;
string b; cin>>b;
int lena = a.length();
size_t pos = b.find(a,);
cout<<pos<<endl;
for(int i = ;i < b.length();i++)
{
//substr()函数
if(i+>=lena&&b.substr(i+-lena,lena)==a){
++sum;
//erase()函数
b.erase(i+-lena,lena);
i-=lena;
}
}
cout<<sum<<endl;
} return ;
}

17-比赛1 B - 子串计算 Chef and his string challenge (string的运用)的更多相关文章

  1. 最长回文子串计算(fail)

    题意: 给定一个字符串s,在s中找到最长的回文子字符串.您可以假设s的最大长度为1000. 例子: 输入: “babad” 输出: “bab” 注: “aba”也是一个有效的答案. 我的答案: 想法: ...

  2. 华为 oj 公共子串计算

    水题,原来以为用dp数组  结果wrong了两次 我想还是自己小题大做了···呵呵·· 献给初学者作为参考 #include <stdio.h> #include <string.h ...

  3. 九度OJ 1149:子串计算 (计数、排序)

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:1026 解决:571 题目描述: 给出一个01字符串(长度不超过100),求其每一个子串出现的次数. 输入: 输入包含多行,每行一个字符串. ...

  4. C++ 基于STL的演讲比赛流程管理系统(sort算法+小型算法(accumulate)+内建函数对象+string字符串拼接+字符串截取+多个容器基础操作+与用户交互+文件的读写+保存+重建+整体文件数据的清空)

    1 /* 2 比赛规则: 3 学校举行一演讲比赛,共12个人参加,比赛两轮,第一轮为淘汰赛 第二轮为决赛 4 每名选手都有对应的编号:如10001~10012 5 比赛方式:分组比赛 每组6人 6 第 ...

  5. 输入计算表达式,将他们存在string【】中

    #include<stdio.h>#include<string>#include<string.h>#include<stdlib.h>#includ ...

  6. 【Java面试题】17 如何把一个逗号分隔的字符串转换为数组? 关于String类中split方法的使用,超级详细!!!

    split 方法:将一个字符串分割为子字符串,然后将结果作为字符串数组返回. stringObj.split([separator],[limit])参数:stringObj   必选项.要被分解的 ...

  7. PHP实用小程序(四)

    <HTML> <HEAD> <TITLE>访问文件时间属性</TITLE> </HEAD> <BODY> <? $Last ...

  8. wifi认证Portal开发系列(四):portal协议的java封装

     一.报文封装类 AbstractPortalMsg.java Portal协议数据报文封装类 package org.yoki.edu.common.protocol.portal.msg; imp ...

  9. java springMVC 极致验证 非demo版

    最近公司项目需要,做了个极致验证,自己在此做下记录. 先上效果图: 它的官网:http://www.geetest.com/   里面有 身份验证.行为验证,  我这使用的为行为验证. 技术文档:ht ...

随机推荐

  1. Gremlin--一种支持对图表操作的语言

    Gremlin 是操作图表的一个非常有用的图灵完备的编程语言.它是一种Java DSL语言,对图表进行查询.分析和操作时使用了大量的XPath. Gremlin可用于创建多关系图表.因为图表.顶点和边 ...

  2. SonarQube代码质量管理平台介绍与搭建

    前 言 1.SonarQube的介绍 SonarQube是一个管理代码质量的开放平台. 可以从七个维度检测代码质量(为什么要用SonarQube): (1) 复杂度分布(complexity):代码复 ...

  3. Azure 2 月新公布

    Azure 2 月新发布:关于虚机和云服务的降价通告,Azure SQL 数据仓库正式发布,Microsoft 认知服务:人脸识别 API 定价模式和名称更新,以及计量名称变更 关于虚机和云服务的降价 ...

  4. mybase修改内部文件免费使用

    关于mybase的介绍就不多说了,下载后一般只有30天的使用期限.以下方法可以无限次使用该软件(当然,每隔一个周期就需要修改myBase.ini) 原文博客详见:https://www.cnblogs ...

  5. 修改FileZilla(FTP客户端)同时传输的文件数

    在菜单中点击“编辑”.“设置”,按照以下步骤操作:

  6. String Painter, Chengdu 2008, LA4394

    题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_ ...

  7. UESTC 1246 拆x3

    用归纳法分析可以知道死循环只有4. 分析一下复杂度,如果n很大并且不是素数,根据基本不等式可以知道 sum factor(n) ≥ 2+n/2 ≍ n/2. 复杂度是O(T*logN*sqrt(N)) ...

  8. 解决Gearman 报sqlite3错误

    删除了系统原带的sqlite3 ,到官网上下一个源码,重新编译安装sqlite3. 如:把sqlite3安装到 /usr/local/sqlite3tar zxf sqlite3.xxxx.tar.g ...

  9. 2017.9.28 web设计简单的购物车应用案例--session的简单应用

    该购物过程是在session范围内完成的,需要使用session对象实现信息的共享 (1)购买“肉类”商品的页面 <%@ page language="java" impor ...

  10. 谷歌浏览器兼容IE插件

    谷歌浏览器兼容IE插件 http://pan.baidu.com/s/1i31hspf