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

过的同学能给看看这段代码为什么WA吗?很短

Posted by YA_ME_DE at 2009-04-27 13:54:59 on Problem 1200
#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:
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