typedeflonglong ll; #define rep(i,a,n) for (ll i=a;i<n;i++) #define per(i,a,n) for (ll i=n;i-->(ll)a;) #define pb push_back #define all(x) (x).begin(), (x).end()
int n; char s0[100]; ll mod;
// (i*j)%mod in GF(2) ll mul(ll i, ll j){ ll res = 0; rep(x, 0, n-1) { if (i & (1LL << x)) res ^= j; j <<= 1; if (j & (1LL << (n - 1))) j ^= mod; // 取mod in GF(2) } return res; }
// (2**i)%mod in GF(2) ll pow2(ll pwr){ ll res = 1; // result ll b = 2; // base while (pwr) { // pwr if (pwr & 1) res = mul(res, b); b = mul(b, b); pwr >>= 1; } return res; }
// v的二进制最高位1在2的多少幂次, high1(3) = 1 inthigh1(ll v){ int leadz = __builtin_clzll(v); // x 前缀0个数 return63 - leadz; }
intmain(){ char *s = s0; scanf("%s",s); n = strlen(s); vector<int> pos; // 只用来判断 <= 2的1 rep(i,0,n){ if (s[i] == '1') pos.push_back(i+1); } per(i,0,n) { // remove trailing zero if(s[i] != '0') break; s[i] = 0; } rep(i,0,n) { // remove prefix zero if(s[0] != '0') break; s++; } int offset = s - s0; // 前导0 n = strlen(s); if (pos.size() == 0) { // all zero printf("-1\n"); return0; } if (pos.size() == 1) { // only 1 of 1 printf("%d %d\n",pos[0],pos[0]+1); return0; } if (pos.size() == 2) { // 恰好2个 printf("%d %d\n",pos[0],pos[1]); return0; } rep(i, 0, n) { // 正向和逆向结果一样的 if (s[i] == '1') mod |= (1LL << i); // s.trim().tobinary() } printf("s: %lld\n",mod);
int h = (n + 1) / 2; // 半长
ll val = mod; ll prod = 1; // (2**h(x)-1)(2**h(x))**(pwr-1) rep(x, 3LL, 1 << h) { // GF(2)乘法还满足结合率 if (!(x & 1)) continue; // x 末位是1 int pwr = 0; // val = x^pwr * ... 相当于 计算GF(2) 中 val的因子和幂次 while (true) { ll curr = val; ll other = 0; rep(bit, 0, n) { if (!(curr & (1LL << bit))) continue; curr ^= x << bit; other ^= 1LL << bit; } if (curr) break; // val = x * other in GF(2) printf("%lld = %lld * %lld\n", val, x, other); val = other; pwr++; } if (pwr) { // x的pwr次方 printf("=> %lld ** %d\n",x,pwr); printf("high1[%lld] = %d\n",x,high1(x)); // prod *= (10-1) * 10 * 10 , 3**3 prod *= (1LL << high1(x)) - 1; rep(y, 1, pwr) prod *= 1LL << high1(x); } } // val 的 一次方 if (val > 1) prod *= (1LL << high1(val)) - 1; // mod => GF(2) => 基的幂次 乘积 => (2的幂次)的幂次和2的(幂次-1) 的 积
ll ans = 1LL << 60; // printf("prod:%lld\n",prod); assert(pow2(prod) == 1); // 2**prod ??????????????????????????????????????????? for (ll x = 1; x * x <= prod; x++) { // 长度一定是prod的因子 ???????????????????????????????? if (prod % x ) continue; if (pow2(x) == 1) ans = min(ans, x); if (pow2(prod / x) == 1) ans = min(ans, prod / x); } printf("%d %lld\n",offset+1,offset+ans+1); }