QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#374705#5273. Hidden DigitszhouhuanyiAC ✓486ms78532kbC++143.5kb2024-04-02 17:18:532024-04-02 17:18:54

Judging History

你现在查看的是最新测评结果

  • [2024-04-02 17:18:54]
  • 评测
  • 测评结果:AC
  • 用时:486ms
  • 内存:78532kb
  • [2024-04-02 17:18:53]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<algorithm>
#define N 10
#define M 1000000
#define W 2000000
#define K 6
using namespace std;
const long long inf=(long long)(1e12);
const long long INF=(long long)(1e18);
int read()
{
	char c=0;
	int sum=0;
	while (c<'0'||c>'9') c=getchar();
	while ('0'<=c&&c<='9') sum=sum*10+c-'0',c=getchar();
	return sum;
}
int T,n,len,ds[M+1],tong[N+1],length,sz[W+1],pw10[K+1],d[N+1],dp[M+1][K+1],dp2[M+1][K+1];
long long F[1<<N],G[1<<N][1<<N],ans;
int calc(int len,int l,int r,int x)
{
	if (l==0&&r==pw10[len]-1) return dp2[x][len];
	if (l/pw10[len-1]==r/pw10[len-1]) return calc(len-1,l%pw10[len-1],r%pw10[len-1],x)&(((1<<10)-1)^(1<<(l/pw10[len-1])));
	else
	{
		int sl=l/pw10[len-1],sr=r/pw10[len-1],res=0;
		for (int i=sl;i<=sr;++i)
		{
			if (i==sl) res|=(calc(len-1,l-i*pw10[len-1],pw10[len-1]-1,x)&(((1<<10)-1)^(1<<i))),x+=((i+1)*pw10[len-1]-l);
			else if (i==sr) res|=(calc(len-1,0,r-i*pw10[len-1],x)&(((1<<10)-1)^(1<<i))),x+=(r-i*pw10[len-1]+1);
			else res|=(calc(len-1,0,pw10[len-1]-1,x)&(((1<<10)-1)^(1<<i))),x+=pw10[len-1];
		}
		return res;
	}
}
bool query(int l,int r)
{
	if (sz[l]==sz[r]) return !calc(sz[l],l,r,0);
	else
	{
		int x=0;
		bool op=1;
		for (int i=sz[l];i<=sz[r];++i)
		{
			if (i==sz[l]) op&=(!calc(i,l,pw10[i]-1,x)),x+=pw10[i]-l;
			else if (i==sz[r]) op&=(!calc(i,pw10[i-1],r,x)),x+=r-pw10[i-1]+1;
			else op&=(!calc(i,pw10[i-1],pw10[i]-1,x)),x+=pw10[i]-pw10[i-1];
		}
		return op;
	}
}
int main()
{
	char c;
	int d;
	long long res;
	for (int i=1;i<=W;++i) sz[i]=sz[i/10]+1;
	pw10[0]=1;
	for (int i=1;i<=6;++i) pw10[i]=pw10[i-1]*10;
	for (int i=0;i<(1<<10);++i) F[i]=inf;
	for (int i=0;i<(1<<10);++i)
		for (int j=0;j<(1<<10);++j)
			G[i][j]=inf;
	for (int i=0;i<(1<<10);++i)
		if (i!=1)
		{
			length=0;
			for (int j=0;j<=9;++j)
				if ((i>>j)&1)
					tong[++length]=j;
			sort(tong+1,tong+length+1);
			if (!tong[1]) swap(tong[1],tong[2]);
			res=0;
			for (int j=1;j<=length;++j) res=res*10+tong[j];
			F[i]=res;
			for (int j=0;j<=8;++j) G[i|((i||j)?(1<<j):0)][i|(1<<(j+1))]=min(G[i|((i||j)?(1<<j):0)][i|(1<<(j+1))],res*10+j);
			for (int j=0;j<=8;++j) G[i|((i||j)?(1<<j):0)|(1<<9)][i|(1<<(j+1))|(1<<0)]=min(G[i|((i||j)?(1<<j):0)|(1<<9)][i|(1<<(j+1))|(1<<0)],res*100+j*10+9);
		}
	F[1]=F[3];
	for (int i=(1<<10)-1;i>=0;--i)
		for (int j=(1<<10)-1;j>=0;--j)
			for (int k=0;k<=9;++k)
			{
				if (!((i>>k)&1)) G[i][j]=min(G[i][j],G[i|(1<<k)][j]);
				if (!((j>>k)&1)) G[i][j]=min(G[i][j],G[i][j|(1<<k)]);
			}
	T=read();
	while (T--)
	{
		n=read(),ans=INF,len=sz[n-1];
		for (int i=0;i<n;++i) cin>>c,ds[i]=c-'0';
		for (int i=0;i<n;++i) dp[i][0]=dp2[i][0]=1<<ds[i];
		for (int i=0;i<n;++i)
			for (int j=1;j<=len;++j)
			{
				dp[i][j]=0;
				for (int k=9;k>=0;--k)
					if (i>=(9-k)*pw10[j-1])
						dp[i][j]|=dp[i-(9-k)*pw10[j-1]][j-1]&(((1<<10)-1)^(1<<k));
			}
		for (int i=n-1;i>=0;--i)
			for (int j=1;j<=len;++j)
			{
				dp2[i][j]=0;
				for (int k=0;k<=9;++k)
					if (i+k*pw10[j-1]<=n-1)
						dp2[i][j]|=dp2[i+k*pw10[j-1]][j-1]&(((1<<10)-1)^(1<<k));
			}
		for (int i=0;i<=n-2;++i)
			if (G[dp[i][len]][dp2[i+1][len]]!=inf)
				ans=min(ans,max(G[dp[i][len]][dp2[i+1][len]],1ll)*pw10[len]+pw10[len]-i-1);
		for (int i=1;i<pw10[len];++i)
			if (query(i,i+n-1))
				ans=min(ans,(long long)(i));
		for (int i=0;i+n-1<pw10[len];++i) d=calc(len,i,i+n-1,0),ans=min(ans,max(F[d],1ll)*pw10[len]+i);
		printf("%lld\n",ans);
	}
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 31ms
memory: 24168kb

input:

6
5
12345
5
01234
3
239
9
998244353
10
1000000007
20
18446744073709551616

output:

1
10
92
45296
701
10367486

result:

ok 6 numbers

Test #2:

score: 0
Accepted
time: 57ms
memory: 24044kb

input:

100
164
69890100410019112111171102121162123121316739414441411451215511811111411666712771777701218561891113156991212202620022134261820122426722022222372222224564295125452559
878
211333331123456484555141518901166516110113417777018311678801199197912200406722012211122121234222892222353322012424228402555...

output:

96
132
439
122
616
93
641
63
683
747
986
754
110
517
415
507
750
110
284
53
843
913
96
495
796
980
350
15
883
976
8
969
432
535
763
951
3
275
936
117
538
382
375
209
615
47
949
624
959
630
824
484
581
761
167
163
938
223
719
284
485
480
430
162
841
459
373
557
794
377
599
809
60
971
414
663
583
894
...

result:

ok 100 numbers

Test #3:

score: 0
Accepted
time: 148ms
memory: 24888kb

input:

100000
8
75332714
10
2593248958
7
2570951
3
900
8
52496150
10
7106318056
4
2000
6
528421
7
8428056
8
14800524
2
85
2
49
2
35
2
04
1
3
9
242194783
2
42
2
78
10
4537960080
3
495
9
955414779
6
834990
6
751167
7
6979405
4
7719
4
2423
6
790165
6
782986
5
26088
4
5677
6
300911
1
0
5
35315
3
142
4
5462
2
3...

output:

12734
235889
2505
99
102592
103677
102
2456
4080
10446
58
48
34
40
3
123491
24
7
36794
48
45967
8092
1572
6495
176
233
5678
26876
2085
75
306
10
1349
123
459
13
127855
1
10739
39
20454
5906
2
13594
460
13470
564
60
124677
2575
250
103468
30
37909
106
2889
1052
36
393
8
1045
10458
4
36
687
9
5788
309...

result:

ok 100000 numbers

Test #4:

score: 0
Accepted
time: 183ms
memory: 23364kb

input:

10000
8
64551991
94
8908239748745103390617336217621091342925136242069726255551754986003838521538075967122990035597
3
366
50
17261403553042681301592228034099763466285593197925
70
6512752606043010515642674438133034556237470965017382180546251858663955
4
1575
14
13738597354878
1
1
44
1271614313865680851...

output:

14586
102345678888
63
10234567869
10234567826
155
578391
1
10234567869
14567927
102345678864
1023688
306717
1023569782
102345678876
102345678864
102345678889
30494
102345678879
5859
10245678898
102345678878
102345678886
102345678882
1236493
102345677
102345678885
102345678878
1235
102345677956
15792...

result:

ok 10000 numbers

Test #5:

score: 0
Accepted
time: 260ms
memory: 23524kb

input:

1000
13
5139990076849
853
4320188783532862415927414556906207860422279569150209288463017070018921778969634469686643059298004525826712396039523006465135975372248365253980074496695105274277279555949598566712425606778209885682018426390381825062981824931051187739167659882723128083674753598607225635089461...

output:

10347958
1023456788870
102345678856
1023456788862
102345678884
1023456788826
1023456788857
1023456788857
1023456788836
1023456788875
1023456788885
102345678882
102345768
10234567878
102345678882
1023456788887
1023456788875
1023456788888
1023456788785
1023456788889
1023456788881
1023456788877
1023456...

result:

ok 1000 numbers

Test #6:

score: 0
Accepted
time: 326ms
memory: 24160kb

input:

100
2473
035240593204479336022647750779505988885071239040880354860105778384171514626457911845962356354493984192931068637984357892651860102331372794324945457430024023431825705858326659002759397047783077893150415556336882933044290118518194229492600555429709728181287147299044130734520980585135713147185...

output:

10234567888882
1023456788876
10234567888889
10234567888866
10234567888883
10234567888846
10234567888886
1234567889966
10234567888872
10234567888876
10234567888850
10234567888879
10234567888862
10234567888871
1023456788877
10234567888864
10234567888872
1234567808889
10234567888889
10234567888872
1023...

result:

ok 100 numbers

Test #7:

score: 0
Accepted
time: 433ms
memory: 28700kb

input:

10
43260
373039883067573264249378597706968049120299430099195084579424045895063448703767926565059241137222919444838185356362113856750039606708109040349124652801223312921209448604305299772630917872017561117475367667875126578670674876143893646726082305715769870366685965942121692036654693410322307072763...

output:

102345678888874
102345678888862
102345678888879
102345678888886
102345678888884
102345678888875
102345678888889
102345678888882
102345678888879
102345678888888

result:

ok 10 numbers

Test #8:

score: 0
Accepted
time: 478ms
memory: 78392kb

input:

1
1000000
54278434494582612477754229700028744890387566738908723965218097889651614007695274259463605843854511093706263884453468838905463774153627559232463324132806122306278886180497036026670553026122641423380003735206971396360375524422896335908112776274550364000216693859506800272613291792797966846872...

output:

1023456788888870

result:

ok 1 number(s): "1023456788888870"

Test #9:

score: 0
Accepted
time: 138ms
memory: 23496kb

input:

100000
1
4
5
78817
1
6
7
0919725
7
6635655
4
1311
5
95155
7
0993133
2
77
2
56
1
2
1
8
4
4666
8
95292926
2
11
5
56774
8
98869074
3
428
9
394197666
3
403
7
0806131
9
855250264
5
97566
1
9
4
4671
7
3739633
8
99999093
5
73334
4
5959
4
5456
5
29553
1
0
4
5747
4
6336
2
33
9
121659444
4
8485
10
7772796022
...

output:

4
1779
6
20789
561
12
49
1390
70
5
2
8
64
2589
10
475
48695
246
16392
304
3607
24855
5669
9
145
356
896
337
588
53
528
10
475
360
30
14691
482
20674
576
91
7077
359
478
29
34748
2379
121
6
1
20390
10589
23463
12564
456
15
3045
4566
10578
36
74
241
4692
825
6080
297
66
133
525
456
4803
14789
89
37
13...

result:

ok 100000 numbers

Test #10:

score: 0
Accepted
time: 155ms
memory: 23160kb

input:

100000
4
1848
5
10265
2
99
5
22999
10
2201048551
3
273
7
3366396
7
6280625
7
1302117
1
9
2
08
7
3724052
4
0769
3
323
7
7216123
8
80156670
7
0423404
1
5
2
75
1
6
1
9
7
1677745
10
3499139394
10
4154414304
9
376667266
7
0060656
2
88
8
63457608
3
526
5
21333
7
2442595
4
2224
6
580333
9
302223970
7
24773...

output:

182
2061
89
287
102542
236
634
20556
10231
9
80
2346
606
31
1257
105668
400
5
57
6
9
1669
3487
10423
2673
600
80
60782
254
128
2544
21
3057
20363
12373
65
9
1028
1
20
14
2375
495
184
3
17494
263
36
10346
97
2374
104
2683
30673
390
12654
93
48091
15634
2094
48
3
2676
2493
858
78
58
4
2589
94
5
13482
...

result:

ok 100000 numbers

Test #11:

score: 0
Accepted
time: 175ms
memory: 23348kb

input:

10000
96
447171718141877884494419781704144077701114171870714496711194174134944774174111974411179714147474
36
968847133499899296239368038796539515
31
0881088809080288208802038030238
90
803596344050050518455001511398521453251018055488304108054418814016808610451878678434018010
98
4474699457465850939458...

output:

147873
236789485
20810
30458091
345789565
1023569
7008
3456185
16924
25680965
1028845
12478888
1038694
2369032
104150
102378906
123406
234958
102357374
13569663
168392
306937
12863
12356904
23460957
145708
2367897
257884
1237924
102456893
1234779
1237045
12356794
103660
20569778
1235601
20569772
102...

result:

ok 10000 numbers

Test #12:

score: 0
Accepted
time: 195ms
memory: 24300kb

input:

10000
54
430997854359097309734504313540357054030733473587434445
69
914510511991453415911555555551594956805990053975090909398959513563355
79
4013696991671146333037010173303301133130403113493742045644036293501793363603333
17
83860865685792753
63
87138077316407193242617503547769091190437574305894554177...

output:

30457892
1053932
103467891
2358686
1034578906
3579127
12374
30678884
1257919
10278391
10246686
5078387
14573
102456768
12369561
102346861
2049559
10234678890
707
1389
1234684
1456892
102568432
204744
2035658
2345595
1023568893
10345918
102349534
304578594
458910
103487946
102568920
10258973
20558
50...

result:

ok 10000 numbers

Test #13:

score: 0
Accepted
time: 253ms
memory: 24888kb

input:

1000
819
629060765628208609787497177670708684878070124600776876080427744410240774742448075787476788886267604744878277426860273099749008062800001436226826878287876420385828086802444740287456750878345768274208272888088877824212690028080264847661709954689872922704921634867070008440784755379220570889777...

output:

406782677
2348454
12580978
10357028
1458954
204589127
20569009
12359352
2489243
4576927
12457866
58913
13589283
2067879
23567149
123696815
60788532
13491797
14682813
23489010
45688976
567890468
10236725
203689273
40679172
204579356
102457140
23689680
1234663
13686864
1687812
56782337
304575939
10579...

result:

ok 1000 numbers

Test #14:

score: 0
Accepted
time: 253ms
memory: 22944kb

input:

1000
872
384441314331188482485651818574138578481881735815421878084830048120113326181218551611253511331885118454213018588688113148848897155287341111418133231832514182128441332128253885141348187548233541858148284245288511822554841868886211311785812818482484841212848142481578428118528848828818388015233...

output:

123458045
4568181
2046894709
345678865
102359371
205792689
16789295
13889221
305791614
1235609782
1236789579
204567364
40589418
1026788920
30794541
34895752
1234568024
10679297
203539
1045678235
3056790549
304689313
12567889290
304567856
1234568015
1024674698
1245809442
10356891848
456789839
1023793...

result:

ok 1000 numbers

Test #15:

score: 0
Accepted
time: 336ms
memory: 26568kb

input:

100
3220
257021870291751511902192922035021567312429429189572595019175217016107221777951117115975591092107911061000012021610170101122011091700050002411177660021110066176017656210111041771002216021602602906100022172677900762667176163110616211273366111471116600175052012110677111771166017011160701720016...

output:

10275902
6789136
235810312
137975593
6072597
125705241
136824151
126709824
30584084
16780808
123839626
2582245
919785
36892251
10675122
50667728
104694587
56817597
305717545
23491524
1474554
23757709
1780956
30466739
25884251
5661306
23491178
23488223
3694163
103461681
10869126
5927011
2571480
14643...

result:

ok 100 numbers

Test #16:

score: 0
Accepted
time: 327ms
memory: 24184kb

input:

100
2450
505710475148582052754838477377857773578350780532537718073303403770044573475311380734036733787776018370370044111187878709308715707385317005811401443524228245707355678777314883408324175870538346447843771144857020105138549348418505530060897801534589134225223701554585443704754544800487504436331...

output:

3045781274
1234789119
258908411
102578219
305683980
10235786741
205682984
4068914727
1247941881
2356790262
2056892159
23456791442
1247890115
1067889544
1346780418
107895096
235692547
10346952806
3456789916
3567890166
203809513
506936996
1067896865
1234693553
234578208
137892391
2567845051
2067890143...

result:

ok 100 numbers

Test #17:

score: 0
Accepted
time: 372ms
memory: 29168kb

input:

10
90258
132130226730302440343001444304044043355409010335036901330737400048400304902033090440000547000421440444422044602934404567444044446440054405574560264064494477040740000440470891444964945104456484010511015104424255555023435383012344054505405055546046554654000400674584884500880099406799042306676...

output:

40318
6845
71170
64005
40098
78263
98363
34815
60877
63229

result:

ok 10 numbers

Test #18:

score: 0
Accepted
time: 404ms
memory: 27380kb

input:

10
8023
1445148643284542292366494446031307164324712444163337224782113423238342612136425347626782423636367664722374778361362129972212374918264502281324146243226322113633332866322444466226424228436546221263618411424884026285861384434134282106206132949322413162292264293133144446222143698113224945364613...

output:

12463672
29449856
347811121
34610587
137811766
238945763
278098606
70822485
6131005
146765073

result:

ok 10 numbers

Test #19:

score: 0
Accepted
time: 398ms
memory: 29208kb

input:

10
54196
434348044060300046684335504404834080330030354334360345433384989496406133300634642004474404260523993634344404314933304091346644334903453300637949493940944860930493443744044434400440210144404324452603463445403004630444334124053444403346430360030536440068064344934433008904044364443444664444046...

output:

304633832
16789188551
34568095692
1236895941
10478422208
1035603209
10259423147
20345604855
146721528
12389086756

result:

ok 10 numbers

Test #20:

score: 0
Accepted
time: 464ms
memory: 78400kb

input:

1
1000000
87766897167755757707375078906166766196676527786012763573601465486757788655676676567566657877778898858868875952976555861997507896166659719526225962956299935937194559566072655975905594677560775999575972889979599779555850077055507057757517772725527057757057039455447007957777067777606576755772...

output:

576783

result:

ok 1 number(s): "576783"

Test #21:

score: 0
Accepted
time: 486ms
memory: 78532kb

input:

1
1000000
18791810998821908811219011042822911980891108103916701993190178919049994211501019795901909662087927917118812116989910912618911100099091109201280111005202909913192190991099900910029590201114160922172002111199090090219200511290119091221212109619909019112211121933122001201111102591259159129962...

output:

290118877

result:

ok 1 number(s): "290118877"

Test #22:

score: 0
Accepted
time: 466ms
memory: 78528kb

input:

1
1000000
73487870738787718888733728878748887848054884373093508473877838374073003384743854883337803407887353303878865387810756104030352038743834887873338875478875578853483874887338773357857858303508759734373094075803880973545738709488964837483776748485445088590473558058808753744873977635973798438933...

output:

30783458701

result:

ok 1 number(s): "30783458701"

Test #23:

score: 0
Accepted
time: 180ms
memory: 24836kb

input:

10000
25
2345678901234567890123456
76
5678901234567890123456789012345678901234567890123456789012345678901234567890
26
90123456789012345678901234
64
7890123456789012345678901234567890123456789012345678901234567890
25
1234567890123456789012345
46
1234567890123456789012345678901234567890123456
60
56789...

output:

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

result:

ok 10000 numbers

Test #24:

score: 0
Accepted
time: 198ms
memory: 22844kb

input:

10000
49
6889092999698900034560091111416119212242278231334
45
555785612666676971734567798183858888012999998
27
171922224522890133336339442
49
4262820123333733014344648955254565890126656769717
73
1156711212345628903333363330423446744055555558961236567890173456777012388
33
0034000090113116181022345672...

output:

86
54
16
24
13
101
77
106
68
100
28
104
87
67
36
62
96
18
49
71
71
97
71
51
93
25
69
12
59
71
39
95
32
32
108
55
47
97
40
27
79
7
38
77
56
58
32
106
79
50
57
75
95
98
93
49
8
84
92
22
92
63
96
17
80
39
97
100
48
25
103
23
20
40
59
100
34
80
18
37
45
62
21
65
10
38
77
106
28
61
19
17
65
39
53
55
64
3...

result:

ok 10000 numbers

Test #25:

score: 0
Accepted
time: 187ms
memory: 24708kb

input:

10000
77
20931003030390000446080000505070501636067667000757000012848608000994967001011
54
670001333307800040404084012545600501666560000170750707
88
0111411111112122271133211117830123441781011555671561116516667177116781818118618191294919
28
5255557896156565759557577675
33
1333563893133456434053345358...

output:

1027
1026
110
551
331
702
215
729
1020
280
973
590
315
765
956
814
793
502
1033
525
921
910
1070
329
1007
909
570
370
948
189
600
84
791
272
597
1064
1025
622
883
1077
834
415
269
323
367
893
351
359
981
623
1016
643
438
684
900
731
1030
853
829
787
1051
818
678
671
144
781
459
758
871
703
823
311
1...

result:

ok 10000 numbers

Test #26:

score: 0
Accepted
time: 181ms
memory: 24068kb

input:

10000
90
669909234569870888486789912995998999930507891109451709099225220099233597838120496784080085
26
89894345974900034775899173
93
789915335978500004567004125456119012542478341235437840454356759515544554566255667643474576454
100
719911395911100034522391163456712612346222933263537390223246482012757...

output:

88966
457888
35387
367187
12609
69129
203591
7025
238781
3680
134839
234079
3700
40910
45322
134217
17853
36772
45900
1028
103418
2367
306909
45741
106071
127850
35970
246070
149072
1354
26905
406719
1069472
178915
206490
253979
5693
1358899
4892
4953
266971
35798
45718
307969
458931
507228
45663
38...

result:

ok 10000 numbers

Test #27:

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

input:

10000
61
7332124456489012355658901234566897723756729212245878901994977
85
4557590126416786311745678781238117899123499739000340608001234562890223452339012345378
29
82042345678505444567495553456
38
67888173476789012348889991294987990923
33
263660327452789082845882991232562
41
2678901224464290155535559...

output:

2737
3154
4528
8966
2365
2335
20673
2659
78268
2772
3961
579
30782
2725
665
4593
1041
5052
757
3528
1454
3665
2659
916
78901
69342
1433
5929
77
429
3928
1743
80355
3006
69290
39
93
7835
539
439
603
2647
3515
45376
104
6824
1429
942
13583
837
8633
3265
10
711
60
9
581
486
3007
3511
9452
50178
357896
...

result:

ok 10000 numbers

Test #28:

score: 0
Accepted
time: 198ms
memory: 23644kb

input:

10000
76
5678921234567890123456739414345678901534567890123456669012345678901284567890
71
16345678601237567890123456789012345978901034567890123456781012345672901
66
890123456888912395678900234567801123456789012342698901233567890123
65
01234567890123456786712345678901284567890193496989012345070901114
...

output:

15
61
878
50
97
4
675
367
261
46
620
138
185
96
19
10
26
4
649
92
832
140
302
153
64
9
235
91
82
210
25
51
16
100
31
79
48
1706
4783
33
34
18
447
1558
74
781
846
467
70
40
1031
401
3
86
9
639
840
58
537
107
19
701
55
683
552
425
28
281
754
57
40
366
462
3558
491
710
36
49
69
25
636
266
67
697
84
75
...

result:

ok 10000 numbers

Test #29:

score: 0
Accepted
time: 253ms
memory: 23608kb

input:

1000
917
234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012...

output:

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

result:

ok 1000 numbers

Test #30:

score: 0
Accepted
time: 240ms
memory: 24144kb

input:

1000
45
444901554557856666456669777745678781234867880
567
22267223333433339014445448405555565896126456789777375678788288888890929959989000305000011111511892122252222313345373901234547440525456589066645668907777577790823856789992349999901234507090111116789222345228233333337330423444444555355675501664...

output:

46
23
13
55
52
45
8
100
68
101
19
43
50
32
24
98
41
89
99
74
39
87
16
61
26
18
42
37
25
106
53
92
11
56
51
9
94
14
70
90
28
81
9
38
87
46
28
38
26
91
12
43
32
80
45
69
57
13
76
63
16
9
66
86
68
69
41
46
107
72
90
76
15
75
79
102
42
69
102
29
84
24
61
36
65
73
16
70
50
41
26
39
38
31
64
41
99
12
11
2...

result:

ok 1000 numbers

Test #31:

score: 0
Accepted
time: 249ms
memory: 23960kb

input:

1000
173
88889010049070909914967199999996989093933973344939567995995459589992396668971979577779998459999992345998901200000090101001109212205200200334007300103456704055045600001600667
892
09616366166166262262220636366686642444678465654655696626666666712645676668284688666166996689000305670077717767812...

output:

895
608
756
819
678
479
759
691
758
379
791
610
917
1067
1001
630
234
504
974
1083
143
633
157
147
827
887
296
1003
1015
198
228
149
238
305
224
255
922
910
517
579
822
849
1042
773
887
350
839
612
591
225
1099
302
106
484
807
528
973
320
848
900
725
349
400
982
596
171
1055
458
789
1033
346
237
114...

result:

ok 1000 numbers

Test #32:

score: 0
Accepted
time: 251ms
memory: 24792kb

input:

1000
597
637800006650749056650565566036560660767000007002360680899000009600660011601166141668121216267291666411639662166161106236567191621656761667776178108211187180963196166220605200026122267210623666222313323332922242566846652456265066266268621632626720222266886612649969663204607063363163716613263...

output:

6035
4148
10162
3831
2453
2433
8600
3389
8222
1225
10877
2276
10264
9569
3428
2395
10790
1260
6914
4140
10473
4843
8283
3449
3733
401
1380
10871
7018
349
1233
5025
6637
4078
2821
7613
5529
7015
6513
8608
4738
9673
4444
7273
6300
8520
9234
4286
10669
2634
9411
2897
2666
9169
6041
3058
7147
8279
10821...

result:

ok 1000 numbers

Test #33:

score: 0
Accepted
time: 243ms
memory: 24920kb

input:

1000
21
888445478888884969884
953
51202226567225122157729111121121551154262595120535053151315671131225237893335351719511551358405231355513325535315037313775301533831155119593951441550545901215114112553222225313344574905454514440524455719055454578501531541590154418589911944575915214551550115511581252...

output:

4880
51257
2661
20582
77470
82851
48350
72527
78061
105804
96322
89197
10625
15325
36440
51372
40906
82995
95418
1399
4896
41500
27867
79680
40500
40655
16849
2024
89849
17538
13023
20375
85789
16254
31740
25174
8888
19997
70378
48020
82587
53183
22800
10329
63912
81828
95938
46555
95687
69003
10460...

result:

ok 1000 numbers

Test #34:

score: 0
Accepted
time: 250ms
memory: 23364kb

input:

1000
355
989018040870011734167792523256288088343678871244477445828458789086688878808274878898863488889019989698901064000891111157719292322675939533563834179994789012595958996295667687728457789012898679589899567890090406009797345678109232207293123406095015440908450007507790063479009072375670998894007...

output:

5678797
164807
1029232
34785531
20365850
12383
128770
3491622
3578333
123425
10249025
2458653
20458444
456744
4792626
15673910
1044976
2472648
1023427
104596431
478065
10376368
1094644
102485556
135823
1668
1950
103130
37894354
129029
135789244
7089518
37896567
5888
26839108
2069525
30619798
349000
...

result:

ok 1000 numbers

Test #35:

score: 0
Accepted
time: 243ms
memory: 23304kb

input:

1000
562
789012305678901234161890122422729013345333941244767890527755775062345678777777577790878477789099345998901234067098181456788022322622901234563898843457049085355678701634567667723477777018348678899234569990100099789112145178991234567298333436789012349678901254565599126456769779397078901284867...

output:

780697
10968
841
63876
27702
33940
80041
27009
258891
24571
39958
35066
168395
12435
1264
53807
479628
9800
26927
82835
681463
88618
3262
3384
14521
828
80496
9219
128036
34188
479846
4790989
256699
74476
367907
34895
74576
90493
1126
235177
702810
86782
46213
571554
48986
15033
30035
70875
7918
708...

result:

ok 1000 numbers

Test #36:

score: 0
Accepted
time: 244ms
memory: 23116kb

input:

1000
676
701234567899129496789012345678901231167890123456289012335678301234567495125456789062385688907237567890123456789012345678901234567800123456789012345672901234567890123459789012545678961634567890123456787812345688801294599890123456789011341678901234527890123456789012345678951234567850123456769...

output:

6779
7368
437
7656
816
8077
3120
2196
8389
10206
3086
8194
8971
71
168
813
775
616
299
970
488
8541
876
475
731
814
921
9034
94
181
8388
94
1046
7584
1038
4216
307
1584
2914
155
9843
470
6433
775
782
2873
497
67
992
994
598
1360
8365
10101
6821
108
767
262
3038
1022
1028
244
2755
630
953
900
71
3112...

result:

ok 1000 numbers

Test #37:

score: 0
Accepted
time: 327ms
memory: 23552kb

input:

100
5453
901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789...

output:

9
10
1
8
8
2
5
7
6
2
8
6
3
10
4
5
2
2
9
3
6
2
7
5
5
2
1
3
10
2
6
5
3
4
7
8
2
6
10
9
9
4
2
8
1
8
5
3
1
5
4
6
10
10
7
8
4
3
6
3
5
3
1
10
9
1
5
4
2
5
4
9
4
10
5
1
2
5
4
1
7
3
10
9
9
8
3
2
7
2
2
6
1
8
4
1
7
6
3
1

result:

ok 100 numbers

Test #38:

score: 0
Accepted
time: 338ms
memory: 24524kb

input:

100
1581
850623666669012777778708838887880929456799012005600001211117190122256289012343673304244447895525556755662666676677234567790888488789019945699901200507891113156111222242272903234567334123456444555545578561636666867173777777888348678909939969890000056780012315118902222267223333353739044345444...

output:

58
31
74
21
86
98
24
100
17
78
106
31
98
44
18
57
55
68
79
88
87
99
63
9
71
78
97
57
53
64
66
11
86
32
20
35
105
89
25
53
108
69
25
39
75
70
14
87
74
11
52
61
30
99
77
62
38
36
64
104
54
105
89
87
32
97
18
75
56
61
66
93
45
98
105
36
53
91
50
75
71
34
96
65
79
95
42
14
67
62
75
101
21
18
8
87
102
56...

result:

ok 100 numbers

Test #39:

score: 0
Accepted
time: 324ms
memory: 23464kb

input:

100
5005
290599991111156719919222698939233599390923454449055999999566699997860773459799099898678999999599890003406780011041601020232560800030306039402300648001554060806106406066070000677908200067800100496799011045178011111117192122116121112333633914441447111155156751166116618607234571891181456789191...

output:

902
869
797
913
701
186
910
550
219
528
139
386
975
533
544
465
860
135
674
144
1059
707
682
155
335
148
563
812
978
260
771
466
820
297
964
692
881
311
601
540
722
976
1049
224
772
181
115
443
459
597
488
655
569
175
740
144
696
979
210
833
580
707
116
1023
1008
324
233
1042
454
715
179
299
1024
96...

result:

ok 100 numbers

Test #40:

score: 0
Accepted
time: 350ms
memory: 24216kb

input:

100
8756
567690447456789086885478409234566860100406700017744613704230447893123436730774055477405734655540640474789005477678973434847840973999989010088080011844161830422882248442345678444434568890855556754042664688971737477780823888848084399679900934960601191411981019399974933934399990149446744053409...

output:

345604665
10373063
1046749385
12345007
60782510
67928932
12688271
456826642
78914496
2692914
104592464
234559825
36925672
102382742
102568496
145792596
457298299
47895614
1059046
491432
47895489
12461659
257851572
1025695568
1025896060
268955723
10575356
356868796
12462927
4695695
40892095
204684176...

result:

ok 100 numbers

Test #41:

score: 0
Accepted
time: 316ms
memory: 24548kb

input:

100
6097
567091113716189212245677903234567890174454784072055578901634567890723756787072345677901274767990128456707082345678108024227898127436789842848478901234565556123858789718348677081238568890193859799002940699901134561810192456789092335679901294567890123455789012396698697234969890978856789012949...

output:

3507705
51951
503816
672952
4817443
343197
2895397
674075
5068142
1543480
596746
1491814
2028892
10888
637274
2372182
107654
1033389
1787402
2509086
2392459
27
781182
270951
345848
601850
30544086
291048
1784799
3781381
237100
787509
5718638
1744654
16727949
1489542
5767226
3570231
5709500
491675
10...

result:

ok 100 numbers

Test #42:

score: 0
Accepted
time: 344ms
memory: 24000kb

input:

100
2508
459789016040678901234567890123456789312343638901436567890123456585662366678607767567890123456789012345678901034067890123456789012342278931234567890123456789052555678901274667890123457779812345878901734597890823456089112345678901238567890123436739012345678901234567850623456789012345678981234...

output:

2594
42888
8479
83217
3094
1410
8149
10691
7270
18693
787715
6665
2441
4613
9967
47878
6126
8602
83654
4438
86892
93972
1635
70528
11220
47419
4011
103744
367457
625
65485
270229
1115
98641
65517
8189
41085
78120
3655
780
83551
61487
3987
3977
481
2959
18984
4830
87339
40712
91280
92120
9560
10544
3...

result:

ok 100 numbers

Test #43:

score: 0
Accepted
time: 388ms
memory: 29760kb

input:

10
98617
567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345...

output:

5
1
3
5
2
6
2
9
1
9

result:

ok 10 numbers

Test #44:

score: 0
Accepted
time: 361ms
memory: 28620kb

input:

10
14745
363334143456789015545555901666566890123757777818345678891934969990003450009112341618121222227223333333339444445444901555567596126666666777777678988234867899129456999000300070901134167192222226782333345378344244464495125555755612645676677737567870188486788912995998900030567091121416181012345...

output:

35
88
23
57
75
105
70
91
61
97

result:

ok 10 numbers

Test #45:

score: 0
Accepted
time: 438ms
memory: 29912kb

input:

10
98169
116889919911198901034520222121151111222322628231322333392443456482012245528202222566697777722789212345278201224569223100030089012333311902232563323333433333413445644453333355836663456386372343677388383338393939436933410304670411214167112143426482032344478344444447895125556749412465668444274...

output:

184
513
850
103
919
1047
333
591
123
986

result:

ok 10 numbers

Test #46:

score: 0
Accepted
time: 384ms
memory: 30712kb

input:

10
21291
836776874103458789912346679907037160400421746171220345222931433567834173446044542345748941276067747770777089080888744901939967440024408788181145618402882528890143436343448444478484235565898843806849077477684988838888898123459889040049070911941591899923252742042345939904894564190155454985966...

output:

14804672
468905573
267818628
1279583159
147903701
1056886421
60736807
682979717
1048731095
3450977685

result:

ok 10 numbers

Test #47:

score: 0
Accepted
time: 431ms
memory: 30992kb

input:

10
76557
066395668971004067090723416181772315672901333567890723456744552345678901276262897177456777712328878909939567820023480789818125671102224527293323486789828444478901554557598123456728022245678901238267190829856789012000970911239567890123456789213335372901444521940123456799996366678907274767870...

output:

26912690
40816592
13493712
131939
12690607
16874003
12903731
562968326
12552493
78904543

result:

ok 10 numbers

Test #48:

score: 0
Accepted
time: 441ms
memory: 28860kb

input:

10
75672
678901234567890123456789012345670901234567890123456729012345678901434567890123456789012345678907234567898183456789012345678900230567890123456789022242628901234563830143446784015345678561234567897123776789082345678901234567800123406709012345618901234167890123456783012345678901534567890663456...

output:

1004876
22666
93083
98192
68169
61970
53663
55258
39951
12881

result:

ok 10 numbers

Test #49:

score: 0
Accepted
time: 38ms
memory: 24404kb

input:

20
100
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
100
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
100
22222222222222222222222222222222222222222222222222222222222222222222222222222222222...

output:

1000
100
200
300
400
500
600
700
800
889
10
1
2
3
4
5
6
7
8
9

result:

ok 20 numbers