题意:求字符串中长度为n的不同子串数目。
string的一个构造函数用法以前没用过
string t(str,i,n);表示string类的t是从str中的第i个元素开始,一共接受n个字符
#include<cstdio>
#include<iostream>
#include<cstring>
#include<queue>
#include<algorithm>
#include<stack>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<map>
using namespace std;
map<string,int> a;
int main()
{
int T,n,nc;
string str;
scanf("%d",&T);
while(T--)
{
cin>>n>>nc>>str;
a.clear();
for(int i=0;i<str.length()-n+1;i++)
{
string substr(str,i,n);
if(a.count(substr)==0)
a[substr]++;
}
cout<<a.size()<<endl;
}
return 0;
}