| ||||||||||
| 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 | |||||||||
过的同学能给看看这段代码为什么WA吗?很短#include <iostream>
using namespace std;
bool hash[17000000];
int N,NC;
char S[17000000];
int ansii[128];
int main()
{
scanf("%d%d",&N,&NC);
scanf("%s",S);
int len=strlen(S);
int sum=0;
int res=0;
for(int i=0;i<=len-N;i++){
sum=0;
for(int j=i;j<i+N;j++){
sum=(sum*NC+ S[j]-97);
}
if(hash[sum]==0){
hash[sum]=1;
res++;
}
}
printf("%d\n",res);
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator