TopCoder

User's AC Ratio

NaN% (0/0)

Submission's AC Ratio

NaN% (0/0)

Tags

Description

Little Petya likes palindromes a lot. Recently he has received a string S, which consists of lowercase letters
of English alphabet and question marks, as a gift from his mother. Each question mark can be replaced with any lowercase English letter with equal probability.


For each position in the string Petya wants to find out an expected value of the length of the longest odd
palindrome centered at that position. A palindrome is considered to be odd if its length is an odd integer.
Output an average value of expected length of the longest odd palindrome for all positions.

Input Format

There are multiple test cases, terminated by EOF.


Each test case contains a string S (1 <= |S| <= 105). This string can contain only lowercase
letters of English alphabet and question marks.

Output Format

For each testcase, output should contain one number - the average value of expected length of the longest odd palindrome for all positions. The answer will be considered correct if an absolute or relative error is not greater than 10-6.

Sample Input 1

ababa
ab?bab

Sample Output 1

2.600000
2.038462

Hints

For the rst sample, expected lengths of the longest odd palindromes for each position are: 1, 3, 5, 3, 1.

For the second sample, expected lengths of the longest odd palindromes for each position are: 1, 14/13, 5, 15/13, 3, 1.
Info: 本題輸出為浮點數,絕對或相對誤差 1e-6 以下視為正確

Problem Source

Migrated from old NTUJ.

2011-2012 Petr Summer Camp pE

Subtasks

No. Testdata Range Score

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 10000 65536 200