atcoder#ABC193D. [ABC193D] Poker
[ABC193D] Poker
Score : points
Problem Statement
We have cards. For each , there are cards with written on it.
We randomly shuffled these cards and handed out five cards - four face up and one face down - to each of Takahashi and Aoki.
You are given a string representing the cards handed out to Takahashi and a string representing the cards handed out to Aoki.
and are strings of five characters each. Each of the first four characters of each string is 1
, 2
, , or 9
, representing the number written on the face-up card. The last character of each string is #
, representing that the card is face down.
Let us define the score of a five-card hand as , where is the number of cards with written on them.
Takahashi wins when the score of Takahashi's hand is higher than that of Aoki's hand.
Find the probability that Takahashi wins.
Constraints
- The first through fourth characters of each of and are
1
,2
, , or9
. - Each of the digit
1
,2
, , and9
appears at most times in total in and . - The fifth character of each of and is
#
.
Input
Input is given from Standard Input in the following format:
Output
Print the probability that Takahashi wins, as a decimal. Your answer will be judged as correct when its absolute or relative error from our answer is at most .
2
1144#
2233#
0.4444444444444444
For example, if Takahashi's hand is 11449
and Aoki's hand is 22338
, Takahashi's score is and Aoki's score is , resulting in Takahashi's win.
Takahashi wins when the number on his face-down card is greater than that of Aoki's face-down card, so Takahashi will win with probability .
2
9988#
1122#
1.0
6
1122#
2228#
0.001932367149758454
Takahashi wins only when Takahashi's hand is 11222
and Aoki's hand is 22281
, with probability .
100000
3226#
3597#
0.6296297942426154