Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <iostream>
- #include <memory.h>
- #include <iterator>
- #include <cassert>
- #include <fstream>
- #include <iomanip>
- #include <cstdlib>
- #include <bitset>
- #include <vector>
- #include <cstdio>
- #include <string>
- #include <queue>
- #include <deque>
- #include <cmath>
- #include <ctime>
- #include <stack>
- #include <set>
- #include <map>
- using namespace std;
- //#define int long long
- #define fi first
- #define se second
- #define pb push_back
- #define mp make_pair
- #define all(x) x.begin() , x.end()
- typedef long long ll;
- typedef long double ld;
- typedef pair < ll , ll > pll;
- typedef pair < int , int > pii;
- template < typename T >
- T read(){
- T p = 1 , x = 0;
- char s = getchar();
- while(s == ' ' || s == '\n') s = getchar();
- if(s == '-') p = -1 , s = getchar();
- while(s >= '0' && s <= '9'){
- x = x * 10 + s - '0';
- s = getchar();
- }
- return x * p;
- }
- template < typename A , typename B >
- void Umax(A &a , const B &b){
- if(a < b)
- a = b;
- }
- template < typename A , typename B >
- void Umin(A &a , const B &b){
- if(a > b){
- a = b;
- }
- }
- ll bin_pow (ll a , ll n) {
- if(n == 0){
- return 1;
- }
- if(n % 2 == 1){
- ll cnt = a * bin_pow(a , n - 1);
- return cnt;
- }
- else {
- ll cnt = bin_pow(a , n / 2);
- return cnt * cnt;
- }
- }
- const int N = (int) 1e5 + 10;
- const int MOD = (int) 1e9 + 7;
- const int INF = (int) 1e9 + 10;
- const ll LLINF = (ll) 1e18 + 10;
- const int dx [] = { 0 , 0 , 1 , -1 };
- const int dy [] = { 1 , -1 , 0 , 0 };
- class HashTable {
- public:
- HashTable(){}
- string find(const string& key);
- string remove(const string& key);
- string genStr(size_t len);
- int getHash(const string& str);
- void insert(const string& key, const string& value);
- private:
- };
- string HashTable::genStr(size_t len) {
- string newStr = "";
- while(len--) {
- newStr += static_cast<char>(rand() % 26 + 'a');
- }
- return newStr;
- }
- int HashTable::getHash(const string& str) {
- int value = 0;
- for(size_t i = 0; i < str.size(); ++i) {
- value = (value * 17 + str[i]) % 1597;
- }
- return value;
- }
- set<int> all;
- int main ()
- {
- freopen("input.txt" , "r" , stdin);
- freopen("output.txt" , "w" , stdout);
- ios_base::sync_with_stdio(false);
- srand(time(NULL));
- for(int i = 0; i < 100; ++i) {
- string z = HashTable.genStr(6);
- int h = HashTable.getHash(z);
- all.insert(h);
- }
- cout << all.size() << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement