P3526 [POI 2011] OKR-Periodicity

题目描述

比托蒂亚的国王 Byteasar 下令对他的臣民的名字进行改革。 比托蒂亚人的名字通常包含重复的短语,例如,名字 Abiabuabiab 包含两次出现的短语 abiab。Byteasar 打算将他的臣民的名字改为与原名长度相匹配的比特序列。 此外,他非常希望在新名字中反映原始的重复。 在下文中,为了简单起见,我们将识别名字中的大小写字母。对于任何字符序列(字母或比特)![](http://main.edu.pl/images/OI18/okr-en-tex.1.png),我们说整数 ![](http://main.edu.pl/images/OI18/okr-en-tex.2.png) (![](http://main.edu.pl/images/OI18/okr-en-tex.3.png)) 是 ![](http://main.edu.pl/images/OI18/okr-en-tex.4.png) 的周期,如果 ![](http://main.edu.pl/images/OI18/okr-en-tex.5.png) 对于所有 ![](http://main.edu.pl/images/OI18/okr-en-tex.6.png) 成立。 我们用 ![](http://main.edu.pl/images/OI18/okr-en-tex.8.png) 表示 ![](http://main.edu.pl/images/OI18/okr-en-tex.7.png) 的所有周期的集合。 例如,![](http://main.edu.pl/images/OI18/okr-en-tex.9.png)、![](http://main.edu.pl/images/OI18/okr-en-tex.10.png) 和 ![](http://main.edu.pl/images/OI18/okr-en-tex.11.png)。 Byteasar 决定每个名字都要改为一个比特序列,该序列: 长度与原名匹配,具有与原名相同的周期集合,是满足上述条件的最小(字典序)比特序列。 例如,名字 ABIABUABIAB 应该改为 01001101001,BABBAB 改为 010010,BABURBAB 改为 01000010。 Byteasar 要求你编写一个程序,帮助将他的臣民的当前名字翻译成新名字。 如果你成功了,你可以作为奖励保留你现在的名字!

输入格式

输出格式

说明/提示

题面翻译由 ChatGPT-4o 提供。