Pagini recente » Cod sursa (job #2613071) | Cod sursa (job #3171092) | Cod sursa (job #2450530) | Cod sursa (job #318428) | Cod sursa (job #104027)
Cod sursa(job #104027)
using namespace std;
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <ctime>
#define maxn 600003
#define maxlog 17
#define pb push_back
vector<int> H[maxn];
inline void insert(int v)
{
int h1=(v%maxn);
//int h2=(v%maxlog);
H[h1].pb(v);
}
inline int find(int v)
{
vector<int>::iterator it, last;
int h1=(v%maxn);
//int h2=(v%maxlog);
for(it=H[h1].begin(), last=H[h1].end(); it!=last;++it)
if(*it==v)return 1;
return 0;
}
int main()
{
srand(time(0));
double start=clock();
for(int i=1;i<=1000000;++i) insert(rand());
for(int i=1;i<=1000000;++i) find(rand());
printf("%lf\n", (clock()-start)/(double)CLOCKS_PER_SEC);
return 0;
}