| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
最后还是靠统计字符的出现次序过的。。。为什么原生态统计ASCII码值对应hash不行呢?哪位路过的大牛给解释一下吧~#include <stdio.h>
#include <string.h>
#define MAX 40000000
bool hash[MAX]={0};
char str[MAX];
int main()
{
int n,nc,len,count=0,flag=0;
scanf ("%d %d",&n,&nc);
scanf ("%s",str);
len=strlen(str);
for (int i=0;i<len;i++)
{
int sum=0;
flag=0;
for (int j=i;j<i+n&&j+n<len;j++)
{
flag=1;
// printf ("%c",str[j]);
sum=sum*nc+str[j];
}
//printf ("\n");
if(!hash[sum]&&flag)
{
hash[sum]=1;
count++;
}
}
printf ("%d\n",count);
//while(1);
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator