字符串哈希模版

const int Max = 26;
int ans;
struct node
{
    char str[80];
    node *next;
    node():next(0){}
}*Head[100010];

void Init()
{
    memset(Head,0,sizeof(Head));
}
bool Hash(char *s)
{
    int len = strlen(s);
    int num = 0 ;
    for(int i=0;istr,s);
        Head[num]=p;
        return true;
    }
    else
    {
        node *p = Head[num];
        while(p)
        {
            if(strcmp(p->str,s)==0)
                return false;
            p=p->next;
        }
        p=new node;
        strcpy(p->str,s);
        p->next = Head[num];
        Head[num] = p;
    }
    return true;
}

你可能感兴趣的:(快速幂)