cswork / OAOpen practice workspace

OtherOA #16

Most Unknown Elements (Part 3 :)

EasyJudge-ready

Topics (AI-labelled)HashingStrings

Compute the Jaccard similarity of character multisets. The source's example shows that repeated characters count and gives 0.4; this site adds non-empty strings and the standard input protocol.

Input

Two lines with non-empty strings containing only lowercase English letters, each of length 1..10^5.

Output

Output the multiset Jaccard similarity: Σmin(countA[c],countB[c]) / Σmax(countA[c],countB[c]), with an error of at most 1e−6.

Example 1

Input:

baa
abbc

Output:

0.400000000000

Example 2

Input:

abc
xyz

Output:

0.000000000000

Example 3

Input:

aaaa
aa

Output:

0.500000000000

Editorial

Loading solution…