| ||||||||||
| 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 | |||||||||
求助,下面代码为什么过不了呢#include<memory.h>
#include<stdio.h>
#include<iostream>
using namespace std;
#define MAX 16000000
int c[MAX];
char str[MAX];
int pow(int d, int l)
{
int t = 1, i;
for(i = 0; i < l; i ++)
t *= d;
return t;
}
int main()
{
int n, nc, i;
while(scanf("%d%d\n",&n,&nc)!=EOF)
{
memset(c,0,sizeof(c));
int tmp,res(0);
scanf("%s",str);
int len = strlen(str);
len = len - n + 1;
for(i = 0; i < len; i++)
{
tmp = 0;
for(int j = 0; j < n; j++)
tmp += (str[i + j] - 'a') * pow(nc, n - j -1);
tmp = abs(tmp)%MAX;
if(!c[tmp])
{
res++;
c[tmp] = 1;
}
}
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