atcoder#ABC295D. [ABC295D] Three Days Ago
[ABC295D] Three Days Ago
Score : points
Problem Statement
The string 20230322
can be rearranged into 02320232
, which is a repetition of 0232
twice.
Similarly, a string consisting of digits is said to be happy when it can be rearranged into (or already is) a repetition of some string twice.
You are given a string consisting of digits. Find the number of pairs of integers satisfying all of the following conditions.
- . ( is the length of .)
- The (contiguous) substring formed of the -th through -th characters of is happy.
Constraints
- is a string consisting of digits whose length is between and , inclusive.
Input
The input is given from Standard Input in the following format:
Output
Print an integer representing the answer.
20230322
4
We have 20230322
.
Here are the four pairs of integers that satisfy the condition: , , , and .
0112223333444445555556666666777777778888888889999999999
185
may begin with 0
.
3141592653589793238462643383279502884197169399375105820974944
9