QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#756030#9555. Strengthucup-team191#AC ✓101ms3728kbC++232.9kb2024-11-16 18:47:022024-11-16 18:47:06

Judging History

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

  • [2024-11-16 18:47:06]
  • 评测
  • 测评结果:AC
  • 用时:101ms
  • 内存:3728kb
  • [2024-11-16 18:47:02]
  • 提交

answer

#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
using ll=long long;
using vi=vector<int>;
using vl=vector<ll>;
using pii=pair<int,int>;
#define pb push_back
#define all(a) begin(a),end(a)

const int N=300010,MOD=1e9+7;
const char en='\n';
const ll LLINF=1ll<<60;

int n;
int sx[22], sz[22];
ll dp[22][2][2];

inline int inter(int l1, int r1, int l2, int r2) {
	return max(0, min(r1, r2) - max(l1, l2) + 1);
}

ll f(int pos, int carry, int pratim) {
	if(pos == 21) return pratim;
	if(dp[pos][carry][pratim] != -1) return dp[pos][carry][pratim];
	int x = sx[pos], z = sz[pos];
	if(!carry) {
		if(x > 0) {
			return dp[pos][carry][pratim] = f(pos + 1, 0, (z > x) || (pratim && z == x));
		} else {
			ll op1 = f(pos + 1, 1, 0) * inter(5, 9, z + 1, 9);
			
			ll op2 = f(pos + 1, (z >= 5), pratim);
			
			ll op3 = f(pos + 1, 1, 1) * inter(5, 9, 0, z - 1);
			
			ll op4 = f(pos + 1, 0, 0) * inter(0, 4, z + 1, 9);
			
			ll op5 = f(pos + 1, 0, 1) * inter(0, 4, 0, z - 1);
			
			//cout << pos << " " << carry << " " << pratim << endl;
			//cout << x << " " << z << endl;
			//cout << "ops : " << op1 << " " << op2 << " " << op3 << " " << op4 << " " << op5 << endl;
			return dp[pos][carry][pratim] = op1 + op2 + op3 + op4 + op5;
		}
	} else {
		if(x > 1) {
			return dp[pos][carry][pratim] = f(pos + 1, 0, (z > x - 1) || (pratim && z == x - 1));
		} else if(x == 1) {
			ll op1 = f(pos + 1, 1, 0) * inter(5, 9, z + 1, 9);
			
			ll op2 = f(pos + 1, (z >= 5), pratim);
			
			ll op3 = f(pos + 1, 1, 1) * inter(5, 9, 0, z - 1);
			
			ll op4 = f(pos + 1, 0, 0) * inter(0, 4, z + 1, 9);
			
			ll op5 = f(pos + 1, 0, 1) * inter(0, 4, 0, z - 1);
			
			ll op6 = 0;
			
			//cout << pos << " " << carry << " " << pratim << endl;
			//cout << x << " " << z << endl;
			//cout << "ops : " << op1 << " " << op2 << " " << op3 << " " << op4 << " " << op5 << endl;
			return dp[pos][carry][pratim] = op1 + op2 + op3 + op4 + op5;
		} else if(x == 0) {
			ll op1 = f(pos + 1, 1, 0) * inter(4, 9, z + 1, 9);
			
			ll op2 = f(pos + 1, (z >= 4), pratim);
			
			ll op3 = f(pos + 1, 1, 1) * inter(4, 9, 0, z - 1);
			
			ll op4 = f(pos + 1, 0, 0) * inter(0, 3, z + 1, 9);
			
			ll op5 = f(pos + 1, 0, 1) * inter(0, 3, 0, z - 1);
			
			ll op6 = 0;
			
			if(sx[pos + 1] > 1)
				op6 = f(pos + 1, 0, (z > 4 || (pratim && z == 4)));
			
			//cout << pos << " " << carry << " " << pratim << endl;
			//cout << x << " " << z << endl;
			//cout << "ops : " << op1 << " " << op2 << " " << op3 << " " << op4 << " " << op5 << endl;
			return dp[pos][carry][pratim] = op1 + op2 + op3 + op4 + op5 + op6;
		
		}
	}	
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int T; cin >> T;
	for(;T--;) {
		memset(dp, -1, sizeof(dp));
		ll lx, lz; cin >> lx >> lz;
		for(int i = 0;i < 21;i++) {
			sx[i] = lx % 10; lx /= 10;
			sz[i] = lz % 10; lz /= 10;
		}
		cout << f(0, 0, 1) << '\n';
	}
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3652kb

input:

5
0 2147483646
10 100
671232353 1232363
123001006660996 3122507962333010
100019990010301090 44519984489341188

output:

2147483647
55
0
1919810
114514

result:

ok 5 number(s): "2147483647 55 0 1919810 114514"

Test #2:

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

input:

100000
983802844195390320 867841388828035681
561712225511657823 824804699460484241
404870597011321334 620779795945179144
108290710733586980 71448325262443207
554396372532342266 866274696506270783
825413569026587006 463721160356652294
954854657812169407 863877305870296520
93529650461135145 7224482112...

output:

0
1
1000
11000
1
0
0
70
100
1
0
100
0
20
0
0
0
0
100
1050
0
0
10
5500
0
100
0
0
0
100
100
59500
1
1
10
100
0
0
0
10
0
100
10
0
100
0
10
10
0
0
0
10500
10
100
10
0
100
0
1000
10
24
1000
1000
0
0
700
0
1000
0
0
100
10
1
0
5000
10
10
0
700
10
1
0
10
0
105
1
100
5500
1
0
100
0
0
10
29012500
100
80
0
700...

result:

ok 100000 numbers

Test #3:

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

input:

100000
100100101001001000 241871790564461103
100100101001001000 855661147750661961
100100101001001000 896900243135796267
100100101001001000 513783969315243904
100100101001001000 534089128945830920
100100101001001000 855891455712467272
100100101001001000 822769449458940477
100100101001001000 27261267...

output:

11860893750000000
38098223671547687
41245349574000000
24555351037500000
24555351037500000
38116205315377100
37249808325000000
14004190260375000
41481294087500000
37003490797725000
19303614665193816
37249808325000000
42802278849438610
41481294087500000
11860893750000000
16092379512500000
287868368000...

result:

ok 100000 numbers

Test #4:

score: 0
Accepted
time: 97ms
memory: 3656kb

input:

100000
1000000000000000000 957512997968887619
1000000000000000000 922920507238342609
1000000000000000000 990971169138689806
1000000000000000000 934649579477343310
1000000000000000000 999730660108208312
1000000000000000000 954708096872168078
1000000000000000000 979183786117650947
1000000000000000000 ...

output:

513068553524443175
478476062793898165
546526724694245362
490205135032898866
555286215663763868
510263652427723634
534739341673206503
529490458837542795
548664760129928238
472781619229996635
485184360746792321
538707030787093693
553991590885355836
486831442281292050
547039286480320752
516609820897215...

result:

ok 100000 numbers

Test #5:

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

input:

100000
0 881341937719391917
0 431276023192975575
0 592093852964812925
0 525654467861191536
0 347546572239293150
0 392443921633282269
0 974615659937363980
0 300345267050133863
0 804808864588612719
0 457764914216738214
0 802598193341206286
0 896184349672589101
0 963089045250048537
0 904903069044744433...

output:

881341937719391918
431276023192975576
592093852964812926
525654467861191537
347546572239293151
392443921633282270
974615659937363981
300345267050133864
804808864588612720
457764914216738215
802598193341206287
896184349672589102
963089045250048538
904903069044744434
996049320107955042
888770207398768...

result:

ok 100000 numbers

Test #6:

score: 0
Accepted
time: 76ms
memory: 3596kb

input:

100000
665168278 546178179932029377
66635116 867921505309634958
945310561 763196012741110977
717637962 742714965215556053
130000097 900963704818491245
513285041 564473154943477861
543677531 60404054788269644
367645182 357106974071909901
115338905 825374015292361415
896431772 8744958006264556
9768187...

output:

546178180
8679215053
41975780660
742714965
95101223881275
5644731550
60404055
357106974
8253740160
8744958
329923473
753921331
514991507
19192934255
342259638
838797957000
824968218
35848926905
711824564
9870284580
8371974180
8281366300
84708006915
309691421
73662888430
3793642780
299294217556125
57...

result:

ok 100000 numbers

Test #7:

score: 0
Accepted
time: 51ms
memory: 3652kb

input:

100000
947850020979955040 543166942
829073435881783314 604005775
618853000395699868 996237784
359727808408688277 182691791
849530805599047150 112670250
332125482592360629 545024060
698871296075568948 664733840
81132957574234141 714741961
618898907861742327 348120143
436291197216861986 180370984
1600...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 100000 numbers

Test #8:

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

input:

100000
10100001001010000 983338066775728921
111100100 938800861716174893
11000101010000 972245555533536920
11000100100000010 963044043689781898
1100000001100010 995749506737729716
10111000000100000 939790937268044435
1000110001100 931378292560777605
10101101000000000 995606363318456725
1111010000000...

output:

74106824855000000
43552380177098000
63277549994799750
59088263257000000
52628739205531150
52153223412500000
53165003351680000
63428022168497000
44362748295738600
65635840639402500
9667230545735000
63602982034790000
47652113709492825
55752233488675000
326394444440000
12220934552807500
125711989091940...

result:

ok 100000 numbers

Test #9:

score: 0
Accepted
time: 101ms
memory: 3596kb

input:

100000
11101000011011011 926451601330317554
100111011101011000 980012799654355014
10010111010111100 914365178504925535
11000101110111010 966353984753480197
11111001100011100 922945224790939327
1010101110101101 947277280713827870
100010111110101001 932003598416345188
11011100110011100 916620779266892...

output:

72936871393750
2482705916562500
2267184102259125
2275988792312500
1733479709567500
495686697500000
434130449900000
2085219287052250
407138035035050
2081792339862500
2643199102500000
2255791518487500
76626957848750
452752715950000
73514333965000
15447635040000
1981531400687500
489013506125000
9310973...

result:

ok 100000 numbers

Test #10:

score: 0
Accepted
time: 93ms
memory: 3656kb

input:

100000
111011011111111010 938034739545618565
111110101011110111 942870184217416845
111111011011111010 953878301421487782
11111010101111111 952117476620803296
11101111010111111 985861618102878890
110011111111110101 936313724389267468
101001111111101111 913504177411108465
111111111001011101 9546642396...

output:

111715673887500
858389355000
111889114043750
1192503750
6341489750
18567626603750
141362264750
18408957906000
19479107207500
18964892528000
175421471250
99310122999750
3821177566125
19490669395000
3801779246750
761442660500
22487720512500
252998750
18349720167500
100964710513000
111715673887500
3040...

result:

ok 100000 numbers

Test #11:

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

input:

100000
90900009009090000 983338066775728921
999900900 938800861716174893
99000909090000 972245555533536920
99000900900000090 963044043689781898
9900000009900090 995749506737729716
90999000000900000 939790937268044435
9000990009900 931378292560777605
90909909000000000 995606363318456725
9999090000000...

output:

10528058362500
10350279492525
10825957405000
10523619461250
11024749419750
10027719722250
10884699989625
10555555550000
10154444439100
11136110525000
10643873100000
11754103413750
10941466090800
10523624446125
9032153991220
11663070496875
11049748093125
11017661484225
10991283817500
11083333327500
1...

result:

ok 100000 numbers

Test #12:

score: 0
Accepted
time: 71ms
memory: 3596kb

input:

100000
99909000099099099 926451601330317554
900999099909099000 980012799654355014
90090999090999900 914365178504925535
99000909990999090 966353984753480197
99999009900099900 922945224790939327
9090909990909909 947277280713827870
900090999990909009 932003598416345188
99099900990099900 916620779266892...

output:

94995000
110775000
99225000
94950000
104682375
94000000
91875000
104186250
0
0
78750000
94950000
99697500
0
94995000
99697500
104445000
94500000
115762500
94999500
116368875
115762500
104499450
0
0
103120500
0
100065000
94999500
94950000
0
110775000
104445000
96810000
99225000
110775000
0
0
10363500...

result:

ok 100000 numbers

Test #13:

score: 0
Accepted
time: 65ms
memory: 3720kb

input:

100000
999090999999999090 999999999999998094
990999990909999099 999999999999997336
999990099990990999 999999999999997779
90999999990999990 999999999999992536
999999090099999099 999999999999995506
999990999090909999 999999999999996192
900999909999999909 999999999999995220
909099999099999990 999999999...

output:

10000
10000
10500
10000
10500
10000
10500
10000
10500
10500
10500
10000
10000
10500
10000
10000
10000
10550
10000
10500
10000
10000
10500
10500
10500
10500
10500
10000
10500
10500
10000
10500
10000
10500
10000
10500
10500
10000
10500
10000
10500
10500
10000
10500
10500
10500
10500
10500
10550
10550
...

result:

ok 100000 numbers

Test #14:

score: 0
Accepted
time: 70ms
memory: 3708kb

input:

100000
0 0
0 1
0 2
0 3
0 4
0 5
0 6
0 7
0 8
0 9
0 10
0 11
0 12
0 13
0 14
0 15
0 16
0 17
0 18
0 19
0 20
0 21
0 22
0 23
0 24
0 25
0 26
0 27
0 28
0 29
0 30
0 31
0 32
0 33
0 34
0 35
0 36
0 37
0 38
0 39
0 40
0 41
0 42
0 43
0 44
0 45
0 46
0 47
0 48
0 49
0 50
0 51
0 52
0 53
0 54
0 55
0 56
0 57
0 58
0 59
0 6...

output:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
...

result:

ok 100000 numbers

Test #15:

score: 0
Accepted
time: 75ms
memory: 3652kb

input:

100000
0 0
0 1
0 2
0 3
0 4
0 5
0 6
0 7
0 8
0 9
0 10
0 11
0 12
0 13
0 14
0 15
0 16
0 17
0 18
0 19
0 20
0 21
0 22
0 23
0 24
0 25
0 26
0 27
0 28
0 29
0 30
0 31
0 32
0 33
0 34
0 35
0 36
0 37
0 38
0 39
0 40
0 41
0 42
0 43
0 44
0 45
0 46
0 47
0 48
0 49
0 50
0 51
0 52
0 53
0 54
0 55
0 56
0 57
0 58
0 59
0 6...

output:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
...

result:

ok 100000 numbers

Test #16:

score: 0
Accepted
time: 68ms
memory: 3628kb

input:

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

output:

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

result:

ok 100000 numbers

Test #17:

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

input:

100000
1000000000000000000 1000000000000000000
1000000000000000000 1000000000000000000
1000000000000000000 1000000000000000000
1000000000000000000 1000000000000000000
1000000000000000000 1000000000000000000
1000000000000000000 1000000000000000000
1000000000000000000 1000000000000000000
1000000000000...

output:

555555555555555556
555555555555555556
555555555555555556
555555555555555556
555555555555555556
555555555555555556
555555555555555556
555555555555555556
555555555555555556
555555555555555556
555555555555555556
555555555555555556
555555555555555556
555555555555555556
555555555555555556
555555555555555...

result:

ok 100000 numbers

Test #18:

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

input:

100000
0 1000000000000000000
0 1000000000000000000
0 1000000000000000000
0 1000000000000000000
0 1000000000000000000
0 1000000000000000000
0 1000000000000000000
0 1000000000000000000
0 1000000000000000000
0 1000000000000000000
0 1000000000000000000
0 1000000000000000000
0 1000000000000000000
0 10000...

output:

1000000000000000001
1000000000000000001
1000000000000000001
1000000000000000001
1000000000000000001
1000000000000000001
1000000000000000001
1000000000000000001
1000000000000000001
1000000000000000001
1000000000000000001
1000000000000000001
1000000000000000001
1000000000000000001
1000000000000000001
...

result:

ok 100000 numbers

Test #19:

score: 0
Accepted
time: 51ms
memory: 3596kb

input:

100000
483294949414741041 1000000000000000000
605360776011703084 1000000000000000000
802510488542163564 1000000000000000000
951055728506980310 1000000000000000000
632942385521579131 1000000000000000000
771020128168174857 1000000000000000000
382918322073494607 1000000000000000000
712161404712297514 1...

output:

55
100000
550
302500
1
550
100
10
55
100
550
1
100
1
100
55000
105
10
100
100
550
1
1000
105000
10
100
1
10
10
100
1
10
1000
1050
10
10
1000
10
10
10000
100
1
100
1000
1000
1000
100
10
10
10
10
105
100
1050
1000
1
100
5500
100
1000
10
100
10500
1
100
550
55
100
55
1
1
1
10500
10
1
1
100
100
10
100
1...

result:

ok 100000 numbers

Test #20:

score: 0
Accepted
time: 73ms
memory: 3652kb

input:

100000
1163 932
656 647
565 1103
1567 1018
1351 1287
47 322
657 582
425 653
1057 1225
882 1068
1180 1558
289 1046
831 445
1099 205
15 98
1126 657
1373 186
7 52
1411 1526
991 622
94 122
654 1559
920 423
1254 815
689 843
1355 890
828 919
825 994
572 246
365 956
1397 558
642 336
1307 699
1462 1310
220 ...

output:

0
0
1
0
0
3
0
1
7
1
10
1
0
0
1
0
0
5
1
0
1
1
0
0
1
0
1
1
0
1
0
0
0
0
20
0
1
0
1
2
55
0
1
1
1
1
3
16
11
2
1
2
1
1
12
0
0
5
1
0
0
52
10
0
0
1
1
0
1
0
1
0
0
3
0
0
1
1
20
1
0
0
0
1
15
0
0
2
0
1
2
637
0
10
1
0
0
0
0
1
0
1
0
2
1
1
1
0
10
7
0
1
1
1
1
10
1
1
0
0
0
0
10
1
1
1
1
1
2
1
0
2
1
1
0
1
0
1
0
1
1
0
...

result:

ok 100000 numbers

Test #21:

score: 0
Accepted
time: 79ms
memory: 3596kb

input:

100000
990000000090000000 999999999999995818
900000090000090000 999999999999996598
990000009 999999999999994521
900009000000009000 999999999999994513
99000900000 999999999999998090
990000000009 999999999999996655
909009000 999999999999993681
90000000000009009 999999999999995457
90090900000 999999999...

output:

1114197466358025
1176028685203875
1055555000000000
1175416521591375
1113605250000000
1055555555000000
1107750000000000
1108333333332750
1108327500000000
1114185802500000
1107750000000000
1175416465913750
1169291605125000
1055000000000000
1163749999938750
1055555550000000
1169845832717625
11083333333...

result:

ok 100000 numbers

Test #22:

score: 0
Accepted
time: 70ms
memory: 3712kb

input:

100000
11498 10792
3597 14285
5181 7607
11041 7790
13145 12555
14028 3553
1155 8315
3264 7
2617 12897
10738 15305
773 13115
2269 6753
8083 7194
9279 6298
4 12402
12259 13224
14607 15098
13652 2030
15181 15772
4950 4002
11583 15437
13203 10310
2274 10796
9901 9881
12988 15279
15691 3062
594 9269
1481...

output:

0
2
1
13
0
0
1
0
2
10
13
1
0
0
1240
1
10
0
1
0
1
0
1
4
1
0
9
0
0
10
0
1
0
10
0
10
0
0
2
0
0
10
1
1
0
1
1
20
210
45
1
1
8
0
0
1
0
1
0
0
0
0
1120
0
1
0
0
0
0
0
55
0
1
1
10
0
0
1
0
1
10
2
0
0
2
0
0
16
3
1
0
50
0
2
0
50
10
2
0
0
0
0
0
0
0
0
10
2
1
25
10
2
0
1
1
0
1
1
10
150
1
1
10
1
0
10
1
0
0
0
1
0
1
2...

result:

ok 100000 numbers

Test #23:

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

input:

100000
1000000000000000000 983047442090047641
1000000000000000000 727393050784596487
1000000000000000000 541438179770067725
1000000000000000000 875210805676911690
1000000000000000000 919564324349164108
1000000000000000000 837262244703631991
1000000000000000000 779243701729807657
1000000000000000000 ...

output:

538602997645603197
282948606340152043
96993735325623281
430766361232467246
475119879904719664
392817800259187547
334799257285363213
215367889008470185
275213377832235933
546959456821131507
208009582968948614
89141025049597222
289438977130419947
395584548114171805
262261955290604670
34637583178413685...

result:

ok 100000 numbers

Extra Test:

score: 0
Extra Test Passed