A Few Good Digits

Submit

Your name:
File:
Open code-statistics:

Language is selected by the extension of the file. See the list of supported languages to know the extension of your language.

Problem

Let f(n) = the number of unique digits in n. For example, f(555) = 1 and f(1123) = 3.

Given an integer N < 10^24, print the number of integers n in [1..N] such that f(n) ≤ 2.

-- mitchs

Options

exec is denied

no deadline, the server will not save your submission

Sample input:_

100
101
102
109
110
985397619389662966119616
993060296846209190740928
3193448638
279134884264206770849590
33333333334
665658687755
9919
3333884505044843853
2222224545542577742
732396549256
909669809
74401805241479609218592
5
6666666
492762302430706481627453
50689772247882109860589
755016917697327093976830
7791
11119911
88888888888777788788
8844
880942904963453356722021
95535554774754
22993521991519511129
949333
777
653303697539
2522148722783
109190914397154959219
5655665555
10000000001
9999989898
505612585275268777361329
268502064955109519092261
11010066101606564504664
88888888855
1001
444444440000004404444444
125176446878400999294612
565
111111111116
10315333715624258052
8466
190223283415763458
223332
100000000
44232446068332457459
144111041100040
73
62471236892
666666666696966669969696
86265498449453015292504
92229397227753375
99999999199991111114114
22222724477421247724
888888
1633138336563633719
857535602179595491716672
1876642524256171630858
885230387442675098474089
188401709118654083397007
2262626226626666262662
626262622226222666266666
36676370
3333282237220728238
6555735555616
669096119913101
66666666
66
99999
211131122985922503
10000
100000000000000001
6556193358
748419534328929
433411444443
100002
180359371641271679917212
777727272772777727
10000002
99999999999999999998
999999999
6666662666
221509
26
387593783299288135621242
97034590115321234789005
4456969798827187
9999999999999999999998
867772402525854823082741
4450202
10000000000000000000002
46
166343228853538837495843
77777457
999911919992112
44444444444444
60
888888888888
111111111311337477
10000000000001
424497903788573831868443
666444665668544845
9999999999999999
975481047085660374632779
99929889882228322858
140411715495629356360350
88888588365
1000000000000000002
2695887915171497566
43434434
800761107867889693796
9999998
922123252148861217384192
894175130633046586115645
888888888
100000001
483021249872272352124212
71175369
23299399237931121
282
448884682100817973302941
119069338918727
33436039340
22222222
227281049052658783435125
43008883160506511920
999
843843570358435930293449
7979949577465616765
10000000000000000000
443444493484488
766872818573841
2222
1111581555281204
100000000000000000000002
745688615600947755951312
35172147750874017545596
9999
10000000000000000
428149225424363470223752
99999998
555885588585858858
1000000000000000
55555555555555555
3300
6
58377
9944994890440407872
444444
9999999999998
240027
3333336643087857066635
6027068637683
33333
777986476948668834
99
3570
36161618214426
47375
99998
49
911929
642519922849177086655465
10000000000002
100000000002
10002
199
9
333333838888
888882707877028207727666
3333333333333336663
666666476667
202301392741482270
983733944701388346606164
1000000000000000000002
2223232233
90541802393013880444026
8772
838607397829180378
10000000
21036770216176666223167
100000000000000000000000
730515687829936700605487
962251252415376494966528
79123002431913208921399
523595394533745404586967
332308245038570242
612002383069908055415499
88888
94969949969669996
666606
6646164464789
888888828
7774777
54116440565
1884036649211
11615212266220818
686666666
221607539620940002778666
99116968
67676667
22002082806659876968007
111111001000001
1
999999999999
7777777777777777777777
66666666666688868
16009505485544290680816
11
756040421276595746006257
7777777777777787667
84715132058160301505
11111111111155115
44444466444006400425
10000000000
994253353329481730493700
3
5336405504302083662399
6613915571924937914
228582565388854564362314
3355568200366
2241131233
22212293793931723
529353314419131907517100
220117720187512
9999999999999998
11116646416737767344
2521519491
2
9999999998
228202468845
945985698783715063042861
928960094297712164950142
431073191152511618399257
99999999
1000000000000000001
11111111
555262565555626566688
444444444444496449
33333335333
2725007533494352217156
786333565769175389382235
6888874444832289324167
82284457773516486825409
10001
128454526800480451550895
1002
87723
52533779962690
100000002
287735810520663048846578
640733430077781672046825
4444444444444444444441
914682430808646039806443
22332333
1000000000000002
18731271542015934970260
33202532561020160
62222646246424652526
2222452232222342399
444050454130434325
18888118888181188
10000000000000000002
93
97
74227
9999999999999999998
77799797997997797777979
6777632642672
16664166164166
44444454445588
100000000000000000002
100000000000000
6666772
999999
392014388670676193034686
885729684711144509842672
2222222222
905072529671738488389210
7512113695237
84848888
661902172419401542546211
999999998
872724
346677250847854927040410
987186694133467181002166
646
9939399939
9999999999
555005005555550
1000000000000000000
713803311833689467876510
3668816395
1698
1000000000
408587542
33003300032020223233
6111166112626616616
555
5555555555555555555
235992685214783952463637
9932029200292508515
111711
145668766548884300134616
9995059404092598629
510447935035988877155448
3161
2626613991569177946586
6666666666666
876526573364023375651827
6439955199603740
780685160569477549397610
8876862559940
987365538889877559
666666666666
78171878938968725114
514686693582352385427446
339367506271730562906
222275644847696976
420993379
553284148886741163616557
71979997
8027222778706
999088088058088777784575
983161611149067797703455
4444443411344330044
5635232853
116666666
555555555555555555555555
1000000001
7175155148557181751834
7
9292
661777771167776166677
450505336948820353377021
638680874626365283045683
100000000000000000
222
3363333666
212339515609978608163411
444444444444444444
440047041494107199
55555557657557774
88882
33
3848308953
55575972592067363768
99999999999998
9360944693069
5155555155115115
4144441411144144444
966896986888869
922942925006
888887728828777795857
9816698094088
11619868833
949683049052247010358082
98734489545093330
694368380403782101980845
10000000000000000000001
908339493122970965556137
5077
298177804877439971684559
100000000000000000001
2182
537415620365875895940646
337143092906249295019644
881526414743294919264060
712106183366779972517849
8949243636642140
4314112128202
22225555222962279
878168200221434089610134
555555558400803330351214
595956894642244063380965
376533340552475343214953
55555555554444
4444434343353444435
9983670887381542289
333333339
6767740564
353336566535556563532
999999999999999999999
8888888
10
10000001
2225225277570625
333
666566555565665556
858
656960215287060410378913
10000000000000000001
9539
444

Sample output:

100
101
101
101
102
1317009655
1327495415
50455
822081831
103630
266223
903
26913415
24152719
278631
38543
574617935
5
7890
977271063
492829023
1153431815
789
10028
79687995
840
1243609343
1272775
50035271
4463
289
262255
394303
85457423
62768
82145
82002
985659671
817887527
342489471
154770
353
939261087
725612847
232
167068
42728023
817
11729631
2550
20080
57997887
1428407
73
129463
1107337586
616560967
10097391
679212359
48417351
4360
23132823
1231026431
187169215
1251997951
749730095
198350222
1068108527
13023
26688143
525863
2182031
16266
66
2151
11877087
928
10615529
65087
2251663
223615
2153
746584367
18518133
9785
84933134
40743
66743
2479
26
899676447
656406847
3717975
339736958
1235220735
6703
339736961
46
741341487
17505
2636023
916460
60
310360
10748959
662537
918550815
17172671
5307183
1312815351
83933719
729807151
154463
21232289
25557647
13453
151124439
9782
1291843831
1279260919
38192
20081
973076759
16735
6273823
152
958003479
1403831
105287
11182
795867431
57408063
351
1224734975
37665383
42465880
1817511
2263951
430
2710383
679475513
1151334663
442497383
927
5307184
918550815
20078
16097645
2653048
7994123
492
6
1591
41575007
3116
662534
2615
214194607
516135
1245
18668207
99
527
867311
1447
2150
49
4413
1073740047
662537
165017
929
127
9
208335
1271527679
26737358
269199
11860703
1317009655
169867721
46827
642775359
827
19118767
9784
379582839
679475512
1145043207
1308621047
601880903
991951127
13253335
1063254287
2000
10181359
3721
532007
38173
8455
121023
365127
5573415
33600
767555887
19551
16473
382073207
1341953
1
330831
297793937
8649549
369097079
11
1155528967
37223047
76675615
5372897
58772023
82144
1329592567
3
249035175
33913463
797964583
425015
47383
6011687
994048279
1491895
5307182
43407951
48663
2
82142
193671
1302329591
1293940983
918550815
20079
21232289
9911
127007215
14678879
103680
204732855
1199569151
281999767
608958791
929
725612847
353
1935
968679
20081
824178983
1073740047
234879401
1289746679
11423
2653049
374339959
6617887
66607663
24263311
14564047
5861115
42465881
93
97
1775
42465878
597517773
547359
723455
917111
84933137
1326016
7901
4671
901773599
1253046527
46366
1285552375
562207
18095
1086322959
40742
4223
884996383
1317009655
249
80325
82143
1977886
21232288
1138751751
53775
403
40744
27095
52740167
33172599
227
31980155
805304615
41482847
2228
734001455
42039903
985659671
487
203815351
539682
1237317887
4193103
1199569151
612375
20576935
269418
74971679
987756823
109902327
12151511
27223
1008728343
16775
589847
1340602615
1317009655
29340295
62719
21159
1023408403
40745
284948887
7
874
135789031
960493847
1073740047
10615528
134
52503
763361583
14678732
14432975
7996935
1994
33
54159
64322095
1326014
632847
3865121
28566375
2556799
314839
159087063
642063
86359
1303378167
10287855
1128265991
339736961
1285552375
611
828373287
84933137
423
998242583
874510623
1244657919
1138751751
4995895
447543
6068575
1239415039
1023605007
1054079247
895482143
998328
29323143
41810527
25443
67671
110688759
169867719
9152
10
9785
3051111
165
17197937
307
1082128655
42465881
883
196

Ranking

Ruby _

RankUserSizeTimeDateStatistics
1mitchs1130.37342016/03/26 08:48:440B / 48B / 61B

Ruby2 _

RankUserSizeTimeDateStatistics
1mitchs1100.23282016/03/26 09:06:280B / 48B / 58B

Perl _

RankUserSizeTimeDateStatistics
1mitchs1040.89292016/03/28 10:28:070B / 30B / 72B
2tails1060.41562016/03/23 23:39:000B / 39B / 65B
3%202890.02742016/03/19 15:08:440B / 81B / 205B

Python _

RankUserSizeTimeDateStatistics
1mitchs1240.12752016/03/26 03:02:020B / 65B / 46B
2mitchs (alt)1260.13902016/03/26 02:56:270B / 66B / 46B
3urupica3050.15922016/06/02 06:17:250B / ?B / ?B
4test5000.12572016/03/17 18:10:210B / ?B / ?B

Python3 _

RankUserSizeTimeDateStatistics
1mitchs1311.36242016/03/26 04:43:390B / 67B / 58B
2mitchs (alt)1340.19112016/03/26 04:38:280B / 67B / 55B

PARI/GP _

RankUserSizeTimeDateStatistics
1mitchs1050.27722016/03/26 02:41:430B / 55B / 50B

bc _

RankUserSizeTimeDateStatistics
1McBusLuck30770.00692020/08/12 22:40:460B / 2676B / 1B

Brainfuck _

RankUserSizeTimeDateStatistics
1mitchs4890.72212016/05/17 08:16:550B / 0B / 489B

GolfScript _

RankUserSizeTimeDateStatistics
1mitchs572.55762016/03/21 07:38:080B / 9B / 48B

gs2 _

RankUserSizeTimeDateStatistics
1mitchs462.99502016/05/11 13:24:0720B / 13B / 12B

Language Ranking_

RankLangUserSizeScore
1gs2mitchs4610000
2GolfScriptmitchs578070
3Perlmitchs1044423
4PARI/GPmitchs1054380
5Ruby2mitchs1104181
6Rubymitchs1134070
7Pythonmitchs1243709
8Python3mitchs1313511
9Brainfuckmitchs489940
10bcMcBusLuck3077149

return to the top page