链接:http://acm.hdu.edu.cn/showproblem.php?pid=1381
题意中的NC不懂有什么用...用的STL里面的map过的.
AC code:
#include <iostream>
#include <map>
#include <cstring>
#include <string>
using namespace std;
int test,N,NC;
string str;
map<string,int> m;
int main()
{
cin>>test;
while (test--)
{
m.clear();
cin>>N>>NC;
cin>>str;
string temp;
int i,length;
length=str.size();
for(i=0;i<=length-N;++i)
{
temp=string(str,i,N); //截取字符串,n代表长度
if(m.count(temp)==0) ++m[temp];
}
cout<<m.size()<<endl;
}
}