CF161C Abracadabra

题目描述

$Ploycarpus$分析了一个名为$abracadabra$的字符串,该字符串是用以下的方法构造的: - 第一步时字符串仅包含单个字符$a$ - 在第$k$步中,我们将第$k-1$步中得到的字符串复制两次,并在这两个串中间插入字母表中的第$k$个字符。$Ploycarpus$所使用的字母表包括小写的拉丁字母和阿拉伯数字,总共$36$个,分别为:第$1$个是$a$,第$2$个是$b$,...,第$26$个是$z$,第$27$个是$0$,第$28$个是$1$,...,第$36$个是$9$。 我们来仔细看一看字符串的构造过程。在第$2$步中,$Ploycarpus$将会把字串"a"复制两次,将字符"b"插在中间,得到字串$aba$。第$3$步会变成"abacaba",第$4$步会变成"abacabadabacaba"。因此,在第$k$步中,字符串会包括$2^k-1$个字符。 $Polycarpus$写下了用以上的方法在$30$步之后得到的字符串然后选择了两个其中的非空子串。你要做的任务是找到两个$Polycarpus$选择的字串的最长公共子串。 一个字符串$s=s_1s_2...s_{|s|}$的子串$s[i...j](1

输入格式

输入包括一行,四个整数$l_1$,$r_1$,$l_2$,$r_2(1

输出格式

输出一个数字,最长公共子串的长度,如果没有,请输出$0$。 注:$Ploycarpus$似乎是人名

说明/提示

In the first sample the first substring is "acab", the second one is "abac". These two substrings have two longest common substrings "ac" and "ab", but we are only interested in their length — 2. In the second sample the first substring is "a", the second one is "c". These two substrings don't have any common characters, so the length of their longest common substring is 0.