求调
查看原帖
求调
216909
Viktley楼主2022/10/17 09:03

为啥全WA了,包括subtask1

#include <cstdio>
#include <iostream>
#define ll long long

using namespace std;

const int N = 1e7 + 10;

int T, l, r, cnt, ans, a[N];
ll f[N];

int main() {
//	freopen("abs.txt", "w", stdout);
	f[1] = 1;
	cnt = 1;
	for (int i = 2; i <= 1000; i++) {
		int t = i, tmp = 0;
		for (int j = 1; j <= i; j++) {
			while(t)
				a[++tmp] = t % 10,
				t /= 10;
			for (int k = tmp; k >= 1; k--)
				f[++cnt] = f[cnt - 1] + a[k] * 1ll;
		}
	}
	scanf("%d", &T);
	while(T--) {
		scanf("%d%d", &l, &r);
		printf("%lld\n", f[r] - f[l - 1]);
	}
	return 0;
}
2022/10/17 09:03
加载中...