现在的位置: 首页 > 综合 > 正文

hdu1381

2013年08月22日 ⁄ 综合 ⁄ 共 425字 ⁄ 字号 评论关闭

链接: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;
	}

}

【上篇】
【下篇】

抱歉!评论已关闭.