#include #include #include #include #include #define lrotl(val,rot) (( (val)<<(rot) )|( (val)>>(sizeof(val)*CHAR_BIT-(rot)) )) const int N=14; static unsigned int x = 123456789; static unsigned int y = 362436069; static unsigned int z = 521288629; static unsigned int w = 88675123; unsigned int xor_rand(){ unsigned int t; t=x^(x<<11); x=y;y=z;z=w; return w=(w^(w>>19)) ^ (t^(t>>8)); } // http://d.hatena.ne.jp/gintenlabo/20100930/1285859540 void xor_srand(unsigned int seed){ #if 1 x^=seed; y^=lrotl(seed,17); z^=lrotl(seed,31); w^=lrotl(seed,18); #else x^=lrotl(seed,14); y^=lrotl(seed,31); z^=lrotl(seed,13); w^=seed; #endif } long long P,B; long long calc(const std::string &s){ long long r=0; __int128_t b=1; int l=s.size(); for(int i=0;ih; long long cnt=0; for(;;cnt++){ if(cnt%1000000==0)fprintf(stderr,"%lld\n",cnt); std::string x; for(int i=0;i