QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#50066#872. Joyful NumbersHuangHanShengAC ✓477ms3760kbC++112.1kb2022-09-24 15:08:542022-09-24 15:08:55

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 18ms
memory: 3708kb

input:

2
1
4

output:

1
2

result:

ok 2 number(s): "1 2"

Test #2:

score: 0
Accepted
time: 17ms
memory: 3672kb

input:

1
1000000000

output:

7

result:

ok 1 number(s): "7"

Test #3:

score: 0
Accepted
time: 18ms
memory: 3592kb

input:

10
1
2
3
4
5
6
7
8
9
10

output:

1
2
2
2
3
3
2
2
3
3

result:

ok 10 numbers

Test #4:

score: 0
Accepted
time: 18ms
memory: 3592kb

input:

10
999999991
999999992
999999993
999999994
999999995
999999996
999999997
999999998
999999999
1000000000

output:

5
6
6
7
7
6
6
6
5
7

result:

ok 10 numbers

Test #5:

score: 0
Accepted
time: 14ms
memory: 3664kb

input:

10
32
9
62
14
76
31
77
62
9
24

output:

3
3
4
4
4
2
5
4
3
3

result:

ok 10 numbers

Test #6:

score: 0
Accepted
time: 18ms
memory: 3760kb

input:

100
232
917
583
995
377
838
788
210
204
151
21
803
761
119
262
391
580
982
806
913
840
27
129
234
601
704
317
581
49
676
925
932
244
768
257
785
883
11
948
110
389
254
949
742
10
857
422
865
830
92
112
540
244
863
173
471
144
418
341
845
908
941
402
535
476
194
515
594
882
254
453
884
666
724
237
21...

output:

3
5
4
5
5
3
4
5
5
3
4
5
4
5
3
4
5
3
5
4
5
3
5
5
4
5
4
5
3
3
4
4
4
3
4
5
4
3
5
5
5
5
5
4
3
5
4
4
5
4
3
4
4
3
4
4
4
4
5
5
4
4
5
4
5
5
5
6
4
5
4
6
5
4
5
5
4
5
5
3
5
4
5
5
4
4
4
4
3
4
4
4
4
6
4
4
3
5
5
5

result:

ok 100 numbers

Test #7:

score: 0
Accepted
time: 27ms
memory: 3748kb

input:

100
971987538
914093604
964244583
924850644
923043291
913356611
964739642
910777513
941966447
974812762
960504375
978958306
958875520
929935610
925926264
933307797
933702996
907774450
904281295
992679895
999563179
945107265
970736983
919138538
984292255
921891421
977320327
935222721
937762694
940914...

output:

7
6
5
7
9
6
7
7
7
7
8
5
5
6
8
6
8
7
8
8
8
6
4
6
6
5
6
6
8
7
7
9
7
8
8
4
7
5
8
6
8
7
4
8
7
7
6
7
6
6
9
9
8
7
6
5
6
7
9
7
4
8
6
5
6
8
7
6
6
5
9
6
6
8
5
9
5
8
7
6
10
4
7
8
7
9
7
5
7
8
4
7
6
5
8
4
7
10
7
6

result:

ok 100 numbers

Test #8:

score: 0
Accepted
time: 19ms
memory: 3660kb

input:

1000
1954
5190
3537
1871
7725
3444
9362
9281
8717
1859
8587
457
5922
3935
6367
6728
4209
7162
9523
8654
4240
8824
8306
6821
5804
8948
8970
6583
5238
9130
7421
3443
4530
5834
9601
8844
9783
1596
9696
6634
1826
7734
6457
5463
2418
7127
205
4674
2125
5520
8899
32
1674
4646
2644
4038
949
7122
6959
7472
...

output:

5
6
5
4
5
7
5
6
5
6
5
3
5
5
3
4
6
5
4
5
4
4
5
5
5
5
6
4
5
6
5
6
6
5
3
7
4
5
4
5
6
7
4
4
6
4
4
7
4
5
5
3
5
5
4
5
5
5
5
5
5
4
5
4
5
5
6
4
7
4
6
6
3
4
4
5
6
5
3
6
4
4
4
4
6
4
4
6
4
5
5
5
3
6
6
5
5
4
6
3
5
6
4
6
5
5
4
6
5
5
3
4
5
7
6
5
5
6
6
4
4
5
4
4
3
4
5
4
5
5
5
6
3
6
6
6
5
5
4
4
5
4
5
3
5
6
4
6
4
6
...

result:

ok 1000 numbers

Test #9:

score: 0
Accepted
time: 43ms
memory: 3668kb

input:

4000
95017
91264
45043
26529
57842
52876
43696
48041
63801
43260
78305
28107
13836
46180
52265
76797
86942
24892
80715
56152
21480
66656
62833
16347
32964
24496
3496
64136
17265
77746
32417
29125
87954
32843
12338
80605
35950
92810
90067
62717
61073
34622
70978
3703
66666
2426
29919
5858
30155
15768...

output:

6
5
4
7
4
5
4
6
7
6
6
4
5
4
6
8
6
6
6
4
5
5
5
5
7
5
5
4
6
3
6
4
7
6
5
6
4
5
5
5
6
5
4
4
6
4
6
6
7
5
4
5
6
4
4
5
5
7
6
6
6
5
5
5
6
6
4
5
4
4
5
5
6
6
5
4
8
6
5
6
6
7
6
7
6
5
4
5
6
4
5
4
7
6
6
5
5
6
5
5
6
5
4
5
5
6
5
5
7
3
5
4
4
4
5
6
6
6
5
5
5
5
6
6
5
7
5
6
4
6
5
6
6
7
6
5
5
7
6
4
5
5
5
4
5
5
4
3
7
6
...

result:

ok 4000 numbers

Test #10:

score: 0
Accepted
time: 381ms
memory: 3732kb

input:

4000
257153178
67580765
750162211
358541798
592600540
404839267
383797906
347530360
644445338
578670380
947289365
742962378
782238069
377872907
615952448
170868596
798248980
505768957
155244266
311267315
104163230
442089502
641516462
67692838
455693633
859002162
390581099
874178513
287345839
3339010...

output:

7
8
6
10
7
5
4
6
6
6
7
6
9
8
8
6
5
5
7
7
7
6
7
4
6
8
8
6
7
7
8
6
5
7
6
9
6
5
4
5
5
5
6
5
9
3
7
6
8
6
4
5
8
6
5
7
9
7
7
7
8
4
9
6
7
5
6
8
7
8
8
5
7
8
9
7
7
5
6
4
6
8
7
5
10
8
8
6
4
6
8
4
8
6
8
8
9
8
6
9
7
5
7
6
9
6
5
7
7
8
8
5
5
6
7
7
6
7
8
8
6
4
8
6
7
6
8
7
7
10
7
6
6
7
5
6
7
6
6
5
6
7
5
7
7
6
7
7
8...

result:

ok 4000 numbers

Test #11:

score: 0
Accepted
time: 477ms
memory: 3668kb

input:

4000
933291427
959496071
967742980
913696544
918952677
902475059
970039741
983367209
901248374
940846478
973429171
985498383
925865422
965658630
968012992
979225101
938048045
917013244
980923536
963729146
916889221
932380062
935683110
910319829
964927582
953544659
987345587
996455707
989196172
91959...

output:

5
6
6
8
8
7
6
10
8
7
7
7
5
7
5
6
8
8
7
6
4
7
8
9
5
9
6
6
6
6
9
4
8
6
7
6
6
6
8
6
9
4
7
4
7
5
6
7
8
8
7
8
7
5
9
8
6
6
5
10
8
6
6
10
9
4
7
7
6
8
7
7
7
9
9
6
7
7
7
7
5
6
10
7
9
6
6
6
6
4
8
7
4
6
6
7
5
8
5
5
8
5
8
6
6
5
9
6
5
6
6
8
5
8
8
9
5
5
5
5
5
8
7
7
6
6
7
6
4
8
8
6
7
7
9
5
7
7
9
7
6
6
7
6
8
7
7
8
...

result:

ok 4000 numbers

Test #12:

score: 0
Accepted
time: 24ms
memory: 3696kb

input:

1000
18433
38917
38923
79889
47123
47129
71707
59419
79901
61471
34847
36901
28711
71719
20521
8233
92203
65579
84011
55339
24623
73771
8237
55351
26683
49211
4157
53309
14401
67651
36931
16453
86083
61507
73
96337
2131
94291
89
82009
73819
2143
73823
96353
41057
8291
34913
82021
30817
12391
10343
5...

output:

4
5
4
5
6
5
5
4
5
4
4
3
4
5
4
4
5
5
4
4
4
3
4
5
4
4
5
5
4
4
4
4
3
3
3
5
4
4
4
5
4
3
4
5
4
4
5
3
4
3
4
5
5
5
4
4
3
5
3
5
4
5
6
6
5
4
3
3
5
4
3
5
4
5
4
4
4
4
5
3
4
4
5
5
5
5
4
5
5
4
5
5
3
4
5
4
4
4
4
3
4
3
3
5
4
4
4
5
3
4
5
5
4
4
5
5
3
4
4
5
4
3
4
5
4
5
4
4
5
4
4
4
5
4
3
4
3
3
4
5
5
5
4
3
3
4
4
5
4
4
...

result:

ok 1000 numbers

Test #13:

score: 0
Accepted
time: 40ms
memory: 3728kb

input:

4000
40961
57347
32771
5
98317
65551
17
49169
98323
57367
73751
49177
81943
65563
16411
73757
57373
31
16417
16421
57383
8231
41
8233
8237
65581
47
24623
90163
57397
24631
41017
59
32831
16447
57413
98377
90187
8269
41039
65617
8273
98387
90197
41047
89
90203
41051
82013
73823
24671
65633
41057
101
...

output:

4
4
4
3
5
4
3
6
4
4
5
4
3
4
4
5
3
2
3
6
4
4
4
4
4
4
3
4
3
4
3
3
4
4
3
5
4
4
4
5
5
5
4
4
4
4
4
5
4
4
4
4
4
4
5
4
4
3
4
4
4
3
5
3
5
5
4
4
3
5
5
2
5
4
5
4
3
4
4
5
3
5
5
5
5
5
4
4
4
4
4
4
3
4
6
3
3
4
3
4
5
5
5
4
4
3
4
5
4
5
4
5
5
4
5
4
4
5
5
4
3
3
4
6
4
4
4
5
4
4
5
5
3
4
4
4
5
3
4
3
3
5
4
6
6
3
5
5
5
4
...

result:

ok 4000 numbers

Test #14:

score: 0
Accepted
time: 43ms
memory: 3664kb

input:

4000
65537
65539
5
90121
11
98317
13
32783
81937
49171
98323
65557
73751
57367
57373
32797
31
81953
90149
57383
8231
41
43
98347
65581
8237
24623
73771
16433
16427
65587
8243
53
41011
81967
73783
49211
90173
16447
65599
32833
41023
67
57413
8263
49223
65609
73
8269
79
90191
65617
98387
82003
90197
9...

output:

5
5
3
3
3
5
3
4
4
4
4
3
5
4
3
4
2
5
5
4
4
4
3
4
4
4
4
3
5
4
4
4
3
3
4
4
4
6
3
4
3
3
3
5
3
5
4
3
4
3
4
5
4
5
4
5
4
5
4
4
5
4
3
4
4
5
3
3
4
4
4
3
3
5
5
4
5
4
5
5
4
3
3
5
5
5
6
4
4
5
4
4
5
3
5
4
5
5
4
5
4
4
4
4
4
5
4
4
4
3
6
4
3
6
4
4
3
5
4
5
5
5
4
5
4
4
4
4
5
5
4
5
5
3
4
4
5
3
5
5
5
3
3
4
3
4
4
4
4
5
...

result:

ok 4000 numbers

Test #15:

score: 0
Accepted
time: 44ms
memory: 3592kb

input:

4000
40961
65539
5
7
90121
81931
98317
90127
32783
24593
81937
19
65551
32789
49169
57367
23
49177
98327
16411
65563
73757
57373
8221
81953
32801
49193
73771
43
98347
24623
81967
16433
49201
41011
90163
81973
47
53
73783
41017
59
90173
41023
16451
49223
32839
65609
73
8269
41039
65617
98387
82003
98...

output:

4
5
3
2
3
3
5
4
4
4
4
3
4
5
6
4
3
4
5
4
4
5
3
3
5
6
4
3
3
4
4
4
5
4
3
3
4
3
3
4
3
4
6
3
4
5
4
4
3
4
5
5
4
5
4
5
5
4
5
5
4
4
4
5
4
3
3
4
3
3
4
4
4
3
5
3
5
5
5
5
6
2
5
5
5
5
3
6
5
5
6
4
5
5
6
4
3
5
5
4
4
5
5
5
3
5
4
4
4
4
4
5
4
5
4
4
4
6
4
4
4
3
4
5
5
5
5
5
5
3
5
5
4
4
5
5
5
5
4
3
5
4
4
5
3
4
3
3
4
6
...

result:

ok 4000 numbers

Test #16:

score: 0
Accepted
time: 158ms
memory: 3700kb

input:

4000
228671489
495116291
638918659
543277061
360521731
702816263
422354951
700440583
955138057
925728787
651214867
442048531
534872089
5849113
109617181
69124127
674111519
476635169
548315171
790405159
614694953
693534761
22478891
202489901
447905839
944996399
206848049
439132217
821837881
105799739...

output:

6
6
5
5
4
4
5
4
4
3
3
5
4
3
4
5
5
7
6
5
6
5
5
5
4
7
6
7
3
6
6
6
6
4
6
5
5
4
6
5
4
5
4
4
5
4
4
6
4
3
5
6
6
5
4
7
5
4
5
4
5
6
6
5
8
5
5
7
5
6
6
4
5
6
5
5
5
5
7
5
6
3
4
3
6
6
5
4
5
7
4
6
3
5
6
5
6
3
4
4
5
6
5
3
5
5
6
6
4
4
5
4
3
6
3
6
4
6
5
6
4
6
5
5
6
4
5
6
4
5
4
3
6
5
5
4
7
6
6
5
6
5
5
5
6
5
5
7
6
4
...

result:

ok 4000 numbers

Test #17:

score: 0
Accepted
time: 152ms
memory: 3696kb

input:

4000
210345991
241426439
142000139
401825803
405446669
613810189
988798991
867557393
505577497
556466201
224174107
235085857
775086113
954933283
76603427
914382899
979173427
590290999
380411963
170434619
550780991
272293951
294641729
312361031
556449863
442302541
56623183
895631441
439853143
1940849...

output:

3
5
5
5
5
5
4
6
5
6
4
4
7
5
6
5
4
6
5
5
5
5
7
4
4
5
3
4
4
4
4
5
5
7
6
7
5
5
6
4
5
6
4
4
4
6
4
7
4
6
4
6
5
5
5
7
5
4
3
6
6
6
4
6
6
5
3
5
5
5
3
4
7
5
3
6
6
6
4
6
6
5
4
7
4
4
3
6
6
5
5
4
4
5
5
6
6
4
3
7
4
4
5
5
4
5
5
5
5
4
6
4
5
4
5
7
4
3
6
5
6
6
5
3
6
5
5
5
4
6
5
5
6
7
5
6
6
4
5
6
5
5
4
5
6
6
5
5
4
4
...

result:

ok 4000 numbers

Test #18:

score: 0
Accepted
time: 158ms
memory: 3740kb

input:

4000
693010433
125698049
250658819
254304257
487882757
804970499
739803143
317997067
104390669
86769679
290275343
815079439
901447699
747618329
496959517
573513757
421503007
798736417
830816291
477151267
929161253
362643499
967221293
290193457
80085041
322224179
658382899
323133493
966680629
5678449...

output:

5
5
6
6
7
6
6
3
6
4
4
5
5
5
5
3
4
4
5
5
7
6
6
3
5
5
5
4
4
7
5
5
5
7
5
5
4
3
6
3
5
4
5
4
4
6
4
4
4
4
5
6
4
5
5
4
7
6
5
5
5
4
8
6
4
4
4
5
5
6
7
6
5
4
7
6
5
6
5
6
5
4
3
6
5
4
4
5
5
3
7
4
5
4
5
4
6
5
6
4
5
4
4
7
5
5
5
6
6
5
5
5
5
4
4
4
6
6
4
5
5
6
6
5
7
4
5
4
7
6
4
4
3
5
5
4
4
4
5
5
7
5
6
4
6
6
6
5
4
4
...

result:

ok 4000 numbers

Test #19:

score: 0
Accepted
time: 160ms
memory: 3756kb

input:

4000
26836993
467550211
979042307
93487109
242253827
656769031
817741831
871186441
968335369
120160259
972021769
360497167
841048081
838402067
935477267
682557467
55836701
589996063
627269663
746430497
630956069
577298471
203120681
490250287
186089521
53911601
916529203
975282229
330776629
445497401...

output:

4
3
5
6
5
5
4
5
4
6
4
3
6
7
5
4
4
5
6
5
6
5
6
4
4
5
3
5
5
5
4
6
4
6
4
5
5
3
4
6
5
6
4
5
5
6
5
5
5
7
6
4
5
3
4
7
7
5
7
5
4
4
5
6
4
3
5
5
5
6
6
4
6
4
5
4
4
5
4
5
4
3
4
6
4
5
5
4
5
4
5
6
5
5
6
4
6
4
5
6
5
4
6
6
5
5
4
6
6
3
7
4
6
6
6
5
3
4
6
5
5
5
5
6
5
5
3
6
5
5
7
5
5
6
6
5
5
4
6
5
5
4
4
3
4
7
4
5
4
3
...

result:

ok 4000 numbers

Test #20:

score: 0
Accepted
time: 199ms
memory: 3592kb

input:

4000
949829633
964354049
979738631
940072967
902889479
920207369
903290893
954679309
985137169
993124373
901185557
990978073
956727323
915251231
989618209
971538467
949518371
992747557
931946537
969818153
960553003
915628073
911999021
963616813
954826793
916086833
996130867
916840499
951640117
92949...

output:

6
6
5
6
6
6
5
5
4
5
6
4
5
6
6
5
7
5
4
4
6
5
5
5
6
5
3
6
7
6
4
5
7
5
5
4
7
7
4
5
4
4
4
6
3
4
6
5
6
4
5
6
4
5
4
6
4
5
4
5
6
8
4
4
4
5
3
6
7
6
6
5
6
4
6
4
8
6
5
6
6
5
5
5
4
5
5
5
5
7
5
4
6
6
4
7
5
5
4
5
3
6
5
5
6
5
5
4
6
6
7
3
5
7
5
5
6
6
5
7
6
4
4
4
5
7
4
6
6
5
3
6
7
6
4
5
3
4
7
4
4
4
5
4
5
4
5
6
4
5
...

result:

ok 4000 numbers

Test #21:

score: 0
Accepted
time: 200ms
memory: 3600kb

input:

4000
904265729
927932417
954400771
960569347
947576837
938008583
965566471
909303817
902864903
975503371
921313291
918888463
981295123
976257043
995409941
929579029
938688539
999645211
902684701
900374561
926433317
986456101
900325417
938311723
901103659
910966829
926367787
942620719
962764849
93048...

output:

5
6
4
5
7
4
6
5
6
5
5
5
5
6
6
4
7
4
4
5
4
3
3
4
7
6
3
6
5
8
3
3
3
4
7
4
4
6
6
4
5
5
5
5
5
4
5
4
6
4
6
5
5
5
5
5
5
4
4
6
5
6
6
4
7
3
6
5
6
4
7
5
6
3
5
5
6
4
5
5
6
6
5
4
6
6
5
4
6
6
6
4
6
4
7
5
4
6
4
4
6
5
7
4
7
4
6
4
7
5
5
6
6
7
8
6
4
5
4
5
6
4
4
4
6
4
6
3
6
5
5
6
5
5
8
4
6
3
5
4
4
4
4
7
5
5
7
4
5
4
...

result:

ok 4000 numbers

Test #22:

score: 0
Accepted
time: 196ms
memory: 3704kb

input:

4000
913489921
980672513
957841411
902496263
908492807
952311817
918355979
980434957
939016207
909705233
949518359
951697433
999260189
953671709
916389919
900530207
972808229
951877673
943767593
966975533
906887213
934518833
975487027
918519859
927588407
987701303
900464699
965795899
964198463
91833...

output:

5
5
4
6
5
3
6
5
4
6
6
5
6
5
6
5
8
5
6
6
5
5
4
5
5
5
6
4
5
4
3
5
6
4
5
5
5
4
4
5
6
6
4
5
6
4
4
5
5
6
3
6
5
5
4
6
5
6
4
5
5
4
7
6
6
5
5
6
4
5
4
3
4
4
5
7
5
3
4
7
4
3
5
5
5
4
6
6
5
4
4
5
5
4
7
5
5
5
5
5
6
5
5
5
7
7
4
5
5
6
5
4
3
6
5
6
5
4
5
5
8
6
6
5
7
6
6
4
5
6
5
6
5
6
5
3
6
4
6
7
4
5
4
3
5
5
4
3
4
6
...

result:

ok 4000 numbers

Test #23:

score: 0
Accepted
time: 190ms
memory: 3744kb

input:

4000
916856833
973791239
973987849
986021899
993263629
931790861
953122831
914530319
918732817
957898769
927006739
979443733
918683671
949755929
900177947
925777949
938770463
961077281
998375459
954064933
953614379
901890091
982736941
996311089
936632371
983105587
999129139
960995383
984416311
91784...

output:

4
6
5
4
5
5
5
6
5
6
6
4
5
6
5
6
6
6
8
4
5
4
5
4
6
4
5
4
4
6
5
5
4
6
5
3
5
6
6
7
6
5
3
4
6
6
5
4
6
5
6
4
6
4
3
4
8
4
5
3
4
4
5
6
5
7
3
5
6
4
4
5
5
6
6
4
5
5
6
5
5
5
5
6
5
7
5
4
5
5
6
6
7
5
6
5
6
5
6
4
4
4
8
7
3
5
3
7
7
6
3
6
7
6
5
6
4
7
7
5
5
5
4
6
4
6
6
6
4
6
6
5
5
6
5
7
4
3
4
6
5
6
7
4
3
4
6
7
3
6
...

result:

ok 4000 numbers