QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#772329#9555. StrengthChen_jrWA 106ms3948kbC++141.6kb2024-11-22 18:47:572024-11-22 18:47:57

Judging History

This is the latest submission verdict.

  • [2024-11-22 18:47:57]
  • Judged
  • Verdict: WA
  • Time: 106ms
  • Memory: 3948kb
  • [2024-11-22 18:47:57]
  • Submitted

answer

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

int bx[22], bz[22];
ll f[22][2][3];
void solve(){
	ll x, z;
	scanf("%lld%lld",&x,&z);
	int cntx = 0, cntz = 0;
	while(x)bx[++cntx] = x % 10, x /= 10;
	while(z)bz[++cntz] = z % 10, z /= 10;
	memset(f, 0, sizeof(f));
	if(bx[1] == 0){
		for(int i = 0; i <= 4; ++i)++f[1][i > bz[1]][0];
		for(int i = 5; i <= 9; ++i)++f[1][i > bz[1]][1];
	}else f[1][bx[1] > bz[1]][0] = 1;
	cntz = max(cntz, cntx);
	for(int i = 2; i <= cntz; ++i){
		for(int upper = 0; upper <= 1; ++upper){
			for(int j = 0; j <= 9; ++j){
				int s = ((j > bz[i]) || (j == bz[i] && upper));
		
				if(bx[i] == 0){
					f[i][s][0] += (j < 4) * (f[i - 1][upper][0] + f[i - 1][upper][1] + f[i - 1][upper][2]) + (j == 4) * f[i - 1][upper][0];
					f[i][s][1] += (j >= 5) * (f[i - 1][upper][0] + f[i - 1][upper][1] + f[i - 1][upper][2]);
					f[i][s][2] += (j == 4) * (f[i - 1][upper][1] + f[i - 1][upper][2]);
				}else if(bx[i] == 1){
					f[i][s][0] += (j <= 4) * (f[i - 1][upper][1] + f[i - 1][upper][2]) + (j == 1) * f[i - 1][upper][0];
					f[i][s][1] += (j >= 5) * (f[i - 1][upper][1] + f[i - 1][upper][2]);
				}else{
					f[i][s][0] += (j == bx[i]) * (f[i - 1][upper][0] + f[i - 1][upper][2]) + (j == bx[i] - 1) * (f[i - 1][upper][1] + f[i - 1][upper][2]);
				}
			}
		}
		// printf("i = %d %lld %lld %lld %lld %lld %lld\n",i, f[i][0][0], f[i][0][1], f[i][0][2],f[i][1][0], f[i][1][1], f[i][1][2]);
	}
	printf("%lld\n",f[cntz][0][0] + f[cntz][0][1] + f[cntz][0][2]);
}

int main(){
	int T; scanf("%d",&T);
	for(int i = 1; i <= T; ++i)solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: -100
Wrong Answer
time: 106ms
memory: 3948kb

input:

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

output:

0
1
1000
203500
1
0
0
0
100
1
0
100
0
0
0
0
0
0
100
1050
0
0
10
5500
1050
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
10
0
1000
0
0
100
10
1
0
0
10
10
0
0
10
1
0
10
0
105
1
100
5500
1
0
100
0
0
10
5802500
100
10
0
0
10
550...

result:

wrong answer 4th numbers differ - expected: '11000', found: '203500'