2280. Selfsimilar Strings

单点时限: 2.0 sec

内存限制: 256 MB

Every few years, a circus comes to your town and presents its latest attractions. This year the main attraction is a man who can construct binary numbers of a given length which are seemingly chaotic: If you shift these numbers to the right (wrapping bits around), you will always get a different number.

You are given several bitstrings s which were produced by the circus man. Your task is to check his ability, i.e. you have to compute all integers 0 <= i < |s|, for which s rotated by i bits to the right is s itself again (this is called a match).

输入格式

The input consists of a number N, followed by a sequence of N lines. Each line contains an unlimited number of X’s and O’s and is terminated by a newline.

输出格式

For each scenario print a line STREAM n where n is the line number of the input starting at 1. Following that line print a number i for all matches in increasing order separated by a single blank. Insert a newline instead of a blank every time appending the number would result in a line longer than 70 characters.

样例

Input
5
XOOOOXOXOOXOXOOXOXOOOXOOOOXOOOOOOXO
XOXO
O
XXXXXXXXXXXXX
XOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXO
Output
STREAM 1
0
STREAM 2
0 2
STREAM 3
0
STREAM 4
0 1 2 3 4 5 6 7 8 9 10 11 12
STREAM 5
0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48
50 52 54 56 58

10 人解决,19 人已尝试。

10 份提交通过,共有 71 份提交。

7.0 EMB 奖励。

创建: 15 年,8 月前.

修改: 6 年,7 月前.

最后提交: 1 年,6 月前.

来源: Freshman Programming Contest

题目标签