Mock CCC '20 Contest 1 J1 - Cryptic Letter

View as PDF

Submit solution

Points: 3
Time limit: 2.0s
Memory limit: 64M

Author:
Problem type
A typical reader of Jonathan's letter.

Jonathan wants to find his true love. As he is only interested in people who are smarter than him, he has decided to send out a puzzle in the form of a letter. Whoever solves the puzzle will be relentlessly pursued by Jonathan to the ends of the Earth.

The letter consists of a single string S, where S is composed only of distinct lowercase letters (no spaces). The goal is to find an anagram made up of only letters found in S. Jonathan wants to know the total number of anagrams, N, that the recipient of the letter will have to consider. It is guaranteed that N \le 10^9.

An anagram is a string formed by rearranging the letters of S, using all letters exactly once. You can consider S to be an anagram of itself.

Input Specification

A single string S.

Output Specification

A single number N.

Sample Input 1

ih

Sample Output 1

2

Sample Input 2

oej

Sample Output 2

6

Comments

There are no comments at the moment.