Please help me!
# include <iostream>
# include <fstream>
# include <cmath>
# include <vector>
# include <algorithm>
# include <math.h>
# include <time.h>
# include <string>
# include <string.h>
# include <map>
# include <queue>
# include <stack>
using namespace std;
const int MAXN = 1000000007;//, Maxn = 1000000009;
long long n, a, san, num, dereje = 1, x;
bool zero, one;
string s, h;
int main()
{
cin >> n >> s >> h;
a = n-1;
for (int i=0; i<n; i++) {
san = (san + (dereje * (s[i]-'a'+1))) % MAXN;
num = (num + (dereje * (h[i]-'a'+1))) % MAXN;
dereje = (dereje * 27) % MAXN;
}
if (san == num) {cout << 0 << '\n'; return 0;}
for (int i=0; i<n; i++) {
san = (san * 27) % MAXN,
san = (san - (((s[a]-'a'+1) * dereje) % MAXN)),
san = (san + MAXN) % MAXN,
san = (san + (s[a]-'a'+1)) % MAXN;
if (san == num) {cout << i+1 << '\n'; return 0;}
a--;
}
cout << -1 << '\n';
return 0;
}
WA 8.why?
i used HASH!
plz help me!