luogu#P3490. [POI2009] FIB-Words 2
[POI2009] FIB-Words 2
题目背景
征求翻译。如果你能提供翻译或者题意简述,请直接发讨论,感谢你的贡献。
题目描述
The following task is a significantly harder version of task Words from the third stage of 16th Polish OI. It wasn't used in the contest itself, but is an extension for those who solved "Words" and want more. :-) Let be a function acting on strings composed of the digits 0 and 1.
The function transforms the string by replacing (independently and concurrently) every digit 0 with 1 and every digit 1 with the string .
For example , (i.e. assigns an empty string to the empty string).
Note that is an injection, or a one-to-one function.
By we denote the function composed with itself times.
In particular, is the identity function .
We are interested in the strings of the form for This sequence begins with the following strings:
, , , , , .
We call the string a substring of the string if it occurs in as a contiguous (i.e. one-block) subsequence.
A sequence of integers is given.
Your task is to check whether a string of the form is a substring of for some , and if it is, you shuold find minimal such .
输入格式
The first line of the standard input contains a single integer , .
The second line of standard input holds non-negative integers (), separated by single spaces.
输出格式
Your programme should print out lines to the standard output, one for each test unit.
Your programm should print to standard output minimal non-negative integer , such that is a substring of , or NIE (no in Polish) if such doesn't exist.
题目大意
题目描述
下面的任务是第16届波兰语竞赛第三阶段的任务“单词”的一个明显的难度增强版本。它并没有在比赛中使用,但对于那些解决了“单词”的人来说,它是一个扩展 :) 。
函数 作用于由数字 和 组成的字符串,其通过将每一个数字 替换为 ,将每一个数字 替换为字符串 来独立且同时地变换字符串 。
例如:
其中例二即把空字符串赋值给空字符串。
注意, 是一个一对一的函数。
我们用 表示函数 使用 次。
特别的, 。
我们对 的 形式的字符串感兴趣,这个序列为:
$$``0", ``1", ``10", ``101", ``10110", ``10110101", \ldots $$如果字符串 在 中以一个连续的(即一个块)子串出现,我们就称 为字符串 的子串。给出整数 的序列。你的任务是检查对于一些 来说, $h^{k_1}(``0") \cdot h^{k_2}(``0") \cdot \ldots \cdot h^{k_n}(``0") $ 形式的字符串是否是 的子串,如果有,你应该找到最小的 。
输入内容
输入的第一行包含一个整数 , 。输入的第二行包含 个非负整数 ,用单个空格分隔。
输出内容
您的程序应该输出 行,每个测试输出一行。你的程序应该输出的最小非负整数 ,使 $h^{k_1}(``0") \cdot h^{k_2}(``0") \cdot \ldots \cdot h^{k_n}(``0") $ 是 的子串。如果不存在 ,则输出 NIE
(波兰语中的 no )。
Translated By in_young_ren
2
1 2
4