Boring Marathon
Tag(s):

## Easy-Medium, Mathematics, Probability distribution, Probability distribution

Problem
Editorial
Analytics

Chintu was part of the Lolympics committee. He had a day off today, so, Chintu decided to watch the 42 km Marathon Finals with Mintu. They started to feel bored after a few minutes. So, they decided to play a game.

They decided a string of length L, and wrote the same string on their respective papers. The string consisted of only upper case letters. Once both of them had a paper with the same string, they started to pick a character from the mentioned string and match if it was same or not. Once an element of a string was picked, they discarded that from their respective strings.

You've to calculate the expected number of times the character both of them picked is same.

Input:
A single line consisting of a number T denoting the number of test cases.
Next T lines consisting of a string of length L having upper case letters.

Output:
Print the expected value upto six decimal places.

Constraints:
1 <= T <= 10
1 <= L <= 105

SAMPLE INPUT
2
AB
TUTY
SAMPLE OUTPUT
1.000000
1.500000

Explanation

For the first test case, we have the string AB. After picking up the letters, we may any of the two sets of strings
1. {AA,BB} = 2 times we will get the same letter
2. {AB,BA} = 0 times we will get the same letter.
So, answer will be (2 + 0) / 2 = 1.0.
Similarly, for the second test case, answer will be 1.5.

Time Limit: 1.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: Bash, C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Swift-4.1, TypeScript, Visual Basic

## CODE EDITOR

Initializing Code Editor...

## This Problem was Asked in

Challenge Name

October Easy '16

OTHER PROBLEMS OF THIS CHALLENGE
• Algorithms > Sorting
• Math > Number Theory
• Algorithms > Dynamic Programming
• Data Structures > Advanced Data Structures
• Algorithms > Graphs