Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

求助,下面代码为什么过不了呢

Posted by zxw090108 at 2011-03-19 19:11:17 on Problem 1200
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator