Processing math: 7%

Problem #364

Nice Fractions

There is a monster who is destroying planet Earth. To counter them, there is a special force of heroes. The heroes are numbered according to their strengths. The strength of the k-th hero is the k-th largest number in the set

S = \{ x \ | \ x = \sum_{i = 1}^{20} \frac{a_i}{6^i}, \ 0 \leq a_i \leq 5 \ \text{for each} \ 1 \leq i \leq 20\}.

Find the strength of the hero who is weaker than 553453543 heroes.

Let M = 10^9 + 7. It can be shown that the answer can be expressed as an irreducible fraction \frac{p}{q}, where p and q are integers and q \not\equiv 0 \pmod{M}.

Output the integer equal to p \cdot q^{-1} \mod M. In other words, output such an integer x that 0 \leq x < M and x \cdot q \equiv p \pmod{M}.

Contributed by SHUBHAM KUMAR VERMA

Solved by 44 users

Log in to submit answers.

Is something wrong?

Maintaining a collection of high quality questions is our top priority. If, however, you do find an error, report the problem and we'll make sure it is reviewed soon.