貌似是多倍经验的,因为https://www.luogu.com.cn/training/591772#problems
本人代码:
#include <bits/stdc++.h>
using namespace std;
long long a1, b1;
long long ans[105];
long long a[105];
void zz(long long cnt){
while (cnt>0){
ans[cnt%10]++;
cnt/=10;
}
}//桶排
int main(){
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
cin>>a1>>b1;
int y, cnt=abs(a1-b1)+1;
int x=cnt/10000;
if (cnt<10000){
for (int i=1; i<=cnt; i++) zz(i);
}else {
for (long long i=1; i<=9999; i++){
zz(i);
}//判断1~9999部分
for (long long i=1; i<=x-1; i++){
memset (a, 0, sizeof(a));
y=i;
while (y>0){
a[y%10]++;
y/=10;
}
for (long long j=0; j<=9; j++){
ans[j]+=a[j]*10000;
}
}
for (long long i=0; i<=9; i++){
ans[i]+=4000*(cnt-1);
}
for (long long i=x*10000; i<=cnt; i++){
zz(i);
}
}
for (long long i=0; i<=9; i++){
cout<<ans[i]<<" ";
}
return 0;
}
样例过了,但不知道错在哪里