UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#166825#2909. numberlpf100879ms2060kbC++111.5kb2022-11-23 21:09:412022-11-23 21:09:42

answer

#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define rep(i, a, b) for(int i = (a); i <= (b); i ++)
#define per(i, a, b) for(int i = (a); i >= (b); i --)
#define Ede(i, u) for(int i = head[u]; i; i = e[i].nxt)
using namespace std;

inline ll read() {
	ll x = 0, f = 1; char c = getchar();
	while(c < '0' || c > '9') f = (c == '-') ? - 1 : 1, c = getchar();
	while(c >= '0' && c <= '9') x = x * 10 + c - 48, c = getchar();
	return x * f;
}

const int blo = 100000;
int s[blo + 10], f[15][110][110]; ll p[15];

int calc(ll x) {return s[x / blo] + s[x % blo];}

void solve(ll x, ll y) {
	y ++;
	ll a = x / 100, b = x % 100;
	ll c = y / 100, d = y % 100; int o = 0;
	if(!a && c) a = 1, b = f[0][0][b];
	while(a < c) {
		while(a % p[o + 1] == 0) o ++;
		if(a + p[o] > c) break;
		b = f[o][calc(a)][b], a += p[o];
	}
	while(true) {
		while(o >= 0 && a + p[o] > c) o --;
		if(o == -1) break;
		b = f[o][calc(a)][b], a += p[o];
	}
	while(b < d) b += calc(a * 100 + b);
	printf("%lld\n", a * 100 + b);
}

int main() {
	p[0] = 1;
	rep(i, 1, 10) p[i] = p[i - 1] * 10;
	rep(i, 1, blo) s[i] = s[i / 10] + (i % 10);
	rep(j, 0, 100) per(k, 99, 0) {
		int v = j + k + s[k];
		if(v < 100) f[0][j][k] = f[0][j][v]; else f[0][j][k] = v % 100;
	}
	rep(i, 1, 10) rep(j, 0, 100) rep(k, 0, 99) {
		f[i][j][k] = k;
		rep(l, 0, min(9, 100 - j))
			f[i][j][k] = f[i - 1][j + l][f[i][j][k]];
	}
	int t = read();
	while(t --) {ll x = read(), y = read(); solve(x, y);}
	return 0;
}

详细

小提示:点击横条可展开更详细的信息

Subtask #1:

score: 20
Accepted

Test #1:

score: 20
Accepted
time: 147ms
memory: 2060kb

input:

500000
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 ...

output:

2
4
4
8
8
8
8
16
16
16
16
16
16
16
16
23
23
23
23
23
23
23
28
28
28
28
28
38
38
38
38
38
38
38
38
38...

result:

ok 500000 lines

Test #2:

score: 0
Accepted
time: 273ms
memory: 2056kb

input:

500000
92 99927
119 99453
481 99268
29 99908
267 99547
835 99500
955 99099
734 99774
306 99883
729 9...

output:

99941
99454
99274
99941
99555
99520
99112
99775
99900
99657
99978
100010
99545
99245
99775
99907
997...

result:

ok 500000 lines

Subtask #2:

score: 25
Accepted

Test #3:

score: 25
Accepted
time: 172ms
memory: 2060kb

input:

500000
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 ...

output:

2
4
4
8
8
8
8
16
16
16
16
16
16
16
16
23
23
23
23
23
23
23
28
28
28
28
28
38
38
38
38
38
38
38
38
38...

result:

ok 500000 lines

Subtask #3:

score: 25
Accepted

Test #4:

score: 25
Accepted
time: 0ms
memory: 2060kb

input:

50
4587480273 4587480273
428862505 500400481
6920415626 7358620174
7787875953 7787884613
4542304779 ...

output:

4587480321
500400482
7358620210
7787884620
4542307848
4676070172
909798356
3555627285
9508855574
511...

result:

ok 50 lines

Subtask #4:

score: 30
Accepted

Test #5:

score: 30
Accepted
time: 287ms
memory: 2056kb

input:

500000
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 ...

output:

2
4
4
8
8
8
8
16
16
16
16
16
16
16
16
23
23
23
23
23
23
23
28
28
28
28
28
38
38
38
38
38
38
38
38
38...

result:

ok 500000 lines