#include #include #include #include using namespace std; const int N = 1e5+10; const int M = 1e6+10; typedef long long llg; const llg oo = 9973; long long extend_gcd(long long a,long long b,long long &x,long long &y) { if(a==0&&b==0) return -1;//无最大公约数 if(b==0){x=1;y=0;return a;} long long d=extend_gcd(b,a%b,y,x); y-=a/b*x; return d; } //*********求逆元素******************* //ax = 1(mod n) long long mod_reverse(long long a,long long n) { long long x,y; long long d=extend_gcd(a,n,x,y); if(d==1) return (x%n+n)%n; else return -1; } int re[10010]; int Hash[N]; char s[N]; int main() { re[1] = 1; for (int i = 2; i