hash小模板

来源:互联网 发布:js cookie时间 编辑:程序博客网 时间:2024/06/06 15:40
#define MAX 1000010struct{    int next,value,num;}edge[MAX]; int e=0; int num=0;int head[MAX]; int hash(int x){    int h = x % MAX;    for(int i = head[h]; i != -1; i = edge[i].next)    {        if(x == edge[i].value)            return edge[i].num;    }    edge[e].value = x;    edge[e].num = num++;    edge[e].next = head[h];    head[h] = e++;    return (num - 1);}

原创粉丝点击