#include<iostream>usingnamespace std;int* Hash;int len, num;int c =0;voidinsert(int x){int index;
c =0;//探测上限
index = x %11;while(Hash[index]!=0&&c<=100){
index =(index +1)% len;
c++;}
Hash[index]= x;}voidfind(int x,int&ok,int&time,int&index){
time =0;
index = x %11;
ok =0;while(Hash[index]!= x && Hash[index]!=0){
index =(index +1)% len;
time++;}if(Hash[index]== x){
ok =1;
index++;}else{
ok =0;}
time++;}intmain(){int t;
cin >> t;while(t--){
cin >> len >> num;
Hash =newint[len];for(int i =0; i < len; i++)Hash[i]=0;for(int i =0; i < num; i++){int temp;
cin >> temp;insert(temp);}for(int i =0; i < len; i++){if(i !=0){if(Hash[i]!=0)cout <<' '<< Hash[i];else cout <<" NULL";}else{if(Hash[i]!=0)cout << Hash[i];else cout <<"NULL";}}
cout << endl;int t1;
cin >> t1;while(t1--){int temp;
cin >> temp;int ok,time, index;find(temp, ok, time, index);if(ok ==1)cout <<1<<' '<< time <<' '<< index << endl;else cout <<0<<' '<< time << endl;}}return0;}
t2
#include<iostream>#include<cmath>usingnamespace std;int* Hash;int len, num;int c =0;voidinsert(int x){int index;
index = x %11;int n =1;int k =1;int g =1;int temp = index;while(Hash[temp]!=0){if(n %2==1){
k =pow(g,2);
g++;}else{
k *=-1;}
temp = index;
temp =(temp + k+len)% len;
n++;}
index = temp;
Hash[index]= x;}voidfind(int x,int& ok,int& time,int& index){
time =0;
index = x %11;
ok =0;int n =1;int k =1;int g =1;int temp = index;while(Hash[temp]!=x&&Hash[temp]!=0){if(n %2==1){
k =pow(g,2);
g++;}else{
k *=-1;}
temp = index;
temp =(temp + k + len)% len;
n++;
time++;}
index = temp;if(Hash[index]== x){
ok =1;
index++;}else{
ok =0;}
time++;}intmain(){int t;
cin >> t;while(t--){
cin >> len >> num;
Hash =newint[len];for(int i =0; i < len; i++)Hash[i]=0;for(int i =0; i < num; i++){int temp;
cin >> temp;insert(temp);}for(int i =0; i < len; i++){if(i !=0){if(Hash[i]!=0)cout <<' '<< Hash[i];else cout <<" NULL";}else{if(Hash[i]!=0)cout << Hash[i];else cout <<"NULL";}}
cout << endl;int t1;
cin >> t1;while(t1--){int temp;
cin >> temp;int ok, time, index;find(temp, ok, time, index);if(ok ==1)cout <<1<<' '<< time <<' '<< index << endl;else cout <<0<<' '<< time << endl;}}return0;}
t3
#include<iostream>#include<cmath>usingnamespace std;struct node
{int data;
node* next;node(){ next =NULL;}node(int data){this->data = data;
next =NULL;}};
node* Hash[11]={NULL};voidinsert(int x){int index = x %11;if(Hash[index]==NULL){
Hash[index]=newnode(x);}else{
node* p =newnode(x);
p->next = Hash[index];
Hash[index]= p;}}voidfind(int x,int&index,int& time,int& ok){
index = x %11;
time =1;for(node* p = Hash[index]; p !=NULL; p = p->next){if(p->data == x){
ok =1;return;}
time++;}
node* p =newnode(x);
p->next = Hash[index];
Hash[index]= p;
ok =0;}intmain(){int num;
cin >> num;for(int i =0; i < num; i++){int temp;
cin >> temp;insert(temp);}int t;
cin >> t;while(t--){int temp,index,time,ok;
cin >> temp;find(temp,index,time,ok);if(ok ==0){
cout <<"error"<< endl;}else{
cout << index <<' '<< time << endl;}}return0;}
t4
#include<iostream>#include<cmath>usingnamespace std;struct node
{int data;
node* next;node(){ next =NULL;}node(int data){this->data = data;
next =NULL;}};
node* Hash[11]={NULL};voidinsert(int x){int index = x %11;if(Hash[index]==NULL){
Hash[index]=newnode(x);}else{
node* q = Hash[index];while(q->next !=NULL)q = q->next;
node* p =newnode(x);
q->next = p;}}voidfind(int x,int& index,int& time,int& ok){
index = x %11;
time =1;if(Hash[index]==NULL){
ok =0;
node* p =newnode(x);
Hash[index]= p;return;}//head not nullfor(node* p = Hash[index]; p !=NULL; p = p->next){if(p->data == x){
ok =1;return;}
time++;}
node* q = Hash[index];while(q->next !=NULL)q = q->next;
node* p =newnode(x);
q->next = p;
ok =0;}intmain(){int num;
cin >> num;for(int i =0; i < num; i++){int temp;
cin >> temp;insert(temp);}int t;
cin >> t;while(t--){int temp, index, time, ok;
cin >> temp;find(temp, index, time, ok);if(ok ==0){
cout <<"error"<< endl;}else{
cout << index <<' '<< time << endl;}}return0;}