题目:
S is a string of length n. S consists of lowercase English alphabets.
Your task is to count the number of different S with the minimum number of distinct sub-palindromes. Sub-palindrome is a palindromic substring.
Two sub-palindromes u and v are distinct if their lengths are different or for some i (0≤i≤length), ui≠vi. For example, string “aaaa” contains only 4 distinct sub-palindromes which are “a”, “aa”, “aaa” and “aaaa”.
传送门:problem 6754
题目大意:求用最少的不同子回文串构成不同的S的字符串的数量,其中,S由小写英文字母组成,子回文串是回文串的子串
思路:
- n=1时,不难发现,S直接由26种英文字母构成即可
- n=2时,最少的不同子回文串有2种, 因为S的类型只可能有XX,XY,YX,这三种,而XX有X,XX两种,XY有X,Y两种,YX同XY, 因此,由于可以重复,此时S的数目就是26*26=676,即每个位置都有26种选择;
- n=3时,最少的不同子回文串有3种,