Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include <string>
- using namespace std;
- const int64_t P = 2017;
- const int64_t MOD = 1000000007;
- const int MAX = 100100;
- int64_t powers[MAX];
- int64_t pref[MAX];
- int64_t rpref[MAX];
- void precalc_powers(int64_t *p, int64_t base, int64_t mod)
- {
- p[0] = 1;
- for (int i = 1; i < MAX; ++i)
- {
- p[i] = p[i - 1] * base % mod;
- }
- }
- void precalc_hash(int64_t *a, string &line, int64_t base, int64_t mod)
- {
- a[0] = 0;
- for (int i = 1; i <= line.size(); ++i)
- {
- a[i] = (a[i - 1] * base + (signed char)line[i - 1]) % mod;
- }
- }
- int64_t get_hash(int l, int r, int64_t *a, int64_t *pows, int64_t mod)
- {
- return (a[r] - a[l] * pows[r - l] % mod + mod) % mod;
- }
- int main()
- {
- string line;
- cin >> line;
- string rline = line;
- reverse(rline.begin(), rline.end());
- precalc_powers(powers, P, MOD);
- precalc_hash(pref, line, P, MOD);
- precalc_hash(rpref, rline, P, MOD);
- int64_t odd_max = -1;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement