A - AABCDDEFE Editorial by evima
Hints → https://atcoder.jp/contests/arc153/editorial/5524
[1] Reduction to \(6\)-tuple
As implied by the problem name, a decimal notation of a beautiful integer can be written as AABCDDEFE using digits A, B, C, D, E, and F, where A is not 0
.
Furthermore, the integer AABCDDEFE corresponds to a \(6\)-tuple (A,B,C,D,E,F) in lexicographical order, so the problem can be reduced to the following one:
find the lexicographically \(N\)-th smallest \(6\)-tuple (A,B,C,D,E,F) of digits where A is not
0
.
[2] Solution 1
There are only \(9\times 10^5\) such \(6\)-tuples, all of which can be listed in time. You can then print the \(N\)-th tuple.
- Sample code (Python): https://atcoder.jp/contests/arc153/submissions/37943916
[3] Solution 2
One can also directly obtain the \(N\)-th tuple. You can simplify the implementation by associating a \(6\)-tuple (A,B,C,D,E,F) with a \(6\)-digit integer ABCDEF.
- Sample code (Python): https://atcoder.jp/contests/arc153/submissions/37943564
posted:
last update: