CARVIEW |
Select Language
HTTP/2 200
date: Tue, 14 Oct 2025 19:50:30 GMT
content-type: text/html; charset=UTF-8
server: cloudflare
x-frame-options: DENY
x-content-type-options: nosniff
x-xss-protection: 1;mode=block
vary: accept-encoding
cf-cache-status: DYNAMIC
content-encoding: gzip
set-cookie: _csrf-frontend=27a2247c46f76d10cb88c98da984293fd8a90c986fdcb603e3039b999cd1caa8a%3A2%3A%7Bi%3A0%3Bs%3A14%3A%22_csrf-frontend%22%3Bi%3A1%3Bs%3A32%3A%22yA0ZyFnrEDnNreXJ9zFe98vPCjtBBhEx%22%3B%7D; HttpOnly; Path=/
cf-ray: 98e99b246b816cd6-BLR
String Hashing (Number of Different Substrings) - Pastebin.com
SHARE
TWEET

String Hashing (Number of Different Substrings)
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int single_hash (const string & s) {
- const int p = 31;
- const int m = 1e9 + 9;
- int64_t hash_value = 0;
- int64_t p_pow = 1;
- for (char c : s) {
- hash_value = (hash_value + (c - 'a' + 1) * p_pow) % m;
- p_pow = (p_pow * p) % m;
- }
- return hash_value;
- }
- int compute_hash (const string & s) {
- int n = (int) s.size();
- const int p = 31;
- const int m = 1e9 + 9;
- vector<int64_t> p_pow(n);
- p_pow[0] = 1;
- for (int i= 1; i < n; ++i) p_pow[i] = (p_pow[i - 1] * p) % m;
- vector<int64_t> h(n + 1,0);
- for (int i = 0; i < n; ++i) {
- h[i + 1] = (h[i] + (s[i] - 'a' + 1) * p_pow[i]) % m;
- }
- //number of different substring(for small length)
- int cnt = 0;
- for (int l = 1; l <= n; ++l) {
- set<int64_t> hs;
- for (int i = 0; i <= n - l; ++i) {
- int64_t cur_h = (h[i + l] + m - h[i]) % m;
- cur_h = (cur_h * p_pow[n - i - 1]) % m;
- hs.insert(cur_h);
- }
- cnt += (int) hs.size();
- }
- return cnt;
- }
Add Comment
Please, Sign In to add comment
-
⭐⭐⭐MAKE $9OO INSTANTLY D M⭐⭐
Java | 5 sec ago | 0.15 KB
-
🚀 Swapzone +37% glitch
JavaScript | 10 sec ago | 0.24 KB
-
⭐⭐⭐GMAIL Logs (2FA disabled)⭐⭐
Java | 18 sec ago | 0.15 KB
-
💎 ChangeNOW Exploit
JavaScript | 19 sec ago | 0.24 KB
-
💡 EASY MONEY GUIDE ✅ Working
JavaScript | 28 sec ago | 0.24 KB
-
⭐⭐⭐ChangeNOW Exploit⭐⭐
Java | 29 sec ago | 0.15 KB
-
⚡ Crypto Swap Glitch ✅ Working ⚡
JavaScript | 37 sec ago | 0.24 KB
-
💵 Make 3000$ in 20 minutes 💵
JavaScript | 46 sec ago | 0.24 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand