atcoder#ARC060D. [ARC060F] 最良表現
[ARC060F] 最良表現
Score : points
Problem Statement
Let be a string of length at least .
We will call a good string, if for any string and any integer , the string obtained by concatenating copies of is different from .
For example, a
, bbc
and cdcdc
are good strings, while aa
, bbbb
and cdcdcd
are not.
Let be a string of length at least . For a sequence consisting of elements, we will call a good representation of , if the following conditions are both satisfied:
- For any , is a good string.
- The string obtained by concatenating in this order, is .
For example, when aabb
, there are five good representations of :
aabb
a
abb
aab
b
a
ab
b
a
a
b
b
Among the good representations of , the ones with the smallest number of elements are called the best representations of .
For example, there are only one best representation of aabb
: aabb
.
You are given a string . Find the following:
- the number of elements of a best representation of
- the number of the best representations of , modulo
(It is guaranteed that a good representation of always exists.)
Constraints
- consists of lowercase letters (
a
-z
).
Partial Score
- points will be awarded for passing the test set satisfying .
Input
The input is given from Standard Input in the following format:
Output
Print lines.
- In the first line, print the number of elements of a best representation of .
- In the second line, print the number of the best representations of , modulo .
aab
1
1
bcbc
2
3
- In this case, there are best representations of elements:-
b
cbc
bc
bc
bcb
c
b
cbc
bc
bc
bcb
c
ddd
3
1