Problem Statement
An introspective number is a positive integer such that each digit of the number tells you the number of occurrences of that digit in that number.
For example, the number 2144424 is introspective because it has one 1, two 2s, and four 4s.
Clearly there are only finitely many introspective numbers.
Suppose we sorted all of them.
Given the
Definition
- Class:
- IntrospectiveNumbers
- Method:
- nth
- Parameters:
- long
- Returns:
- String
- Method signature:
- String nth(long index)
- (be sure your method is public)
Notes
- The total number of introspective numbers is greater than 10^18, so for any input that matches the constraints given below the return value is defined.
Constraints
- index will be between 0 and 10^18, inclusive.
Examples
0
Returns: "1"
The smallest introspective number (i.e., the one at index 0) is clearly the number 1.
5
Returns: "333"
The only two-digit introspective number is 22. The three-digit ones are 122, 212, 221, and 333.
128
Returns: "2144424"
The correct answer for this index is the number mentioned in the statement.
266960
Returns: "999299999912"
1
Returns: "22"
2
Returns: "122"
3
Returns: "212"
4
Returns: "221"
6
Returns: "1333"
7
Returns: "3133"
8
Returns: "3313"
9
Returns: "3331"
10
Returns: "4444"
11
Returns: "14444"
4718803
Returns: "55777755772572"
255999072
Returns: "17374427237774734"
104554406420
Returns: "52656453643635626454"
5955217264
Returns: "1577757766667655567"
550195858414
Returns: "275253475457747743357"
128654
Returns: "412555445452"
71655287405291
Returns: "88835145483828525488354"
420843416012567979
Returns: "2745241346576776356455376767"
56300
Returns: "55335512523"
398384431
Returns: "34743777737414227"
60055185958015
Returns: "76747217676763243644673"
404568667768
Returns: "245551364462653566436"
1408496021539386
Returns: "6362638881858855288356656"
2507971
Returns: "36663413646446"
14823990
Returns: "266344263643664"
5380883297
Returns: "1266767677733663772"
3158239170747
Returns: "1577372445374557475732"
1310277910
Returns: "238488888124438483"
885316765509372
Returns: "4633657573577764675746546"
123498538724723365
Returns: "746247547542356766566773573"
19608173632
Returns: "6276736763662713777"
1744200488
Returns: "344999999439294239"
123607717077
Returns: "55646564436245625363"
94494
Returns: "254544551452"
390160982005
Returns: "243664552345546656361"
33064496
Returns: "451543355234452"
85092
Returns: "236666316362"
276590639
Returns: "23437142374477777"
1193
Returns: "244434323"
6643732625
Returns: "2373777726737616666"
934493921437297340
Returns: "4536776244635766176437552577"
431483439188104222
Returns: "2756646735626737467557144357"
885273382061506565
Returns: "4446725676555457763277363176"
710734785047140248
Returns: "3745174342377766676525756546"
711707653598957062
Returns: "3745576756752446172566737346"
745937495250479787
Returns: "3767644643546527527167775536"
966382316436087433
Returns: "4565747522167776666573434573"
675144401062860363
Returns: "3671533675655427564764764772"
253686940656174981
Returns: "1773675724476545567636462753"
507644075228405428
Returns: "3355755544887318788788874477"
222156015705657670
Returns: "1654377765577344657262436675"
551634392267340642
Returns: "3466734177657447256557636527"
239058362267163199
Returns: "1737746256665576756734452473"
123467908318593041
Returns: "745884782855858778471747285"
852116347142611986
Returns: "4364775323766442775665551677"
666728583426574532
Returns: "3665267275576375776461435744"
618052119438884224
Returns: "3576563472755445647361266777"
134613693185048385
Returns: "766723188863868678787826773"
521805685870184105
Returns: "3388865848626686564453824585"
762425824415489436
Returns: "3777646747267542536634155657"