30pts求调qwq
查看原帖
30pts求调qwq
1214345
iamacreeper楼主2025/7/20 12:11

3AC 7WA

#include<bits/stdc++.h>
#define int unsigned long long
using namespace std;
int a[15],b[15],n,m,y;
void calc(int x,int v){
    while(x>0) a[x%10]+=v,x/=10;
}
void calc2(int x,int v){
    while(x>0) b[x%10]+=v,x/=10;
}             
signed main(){
	cin>>n;
    if(n<10000) for(int i=1;i<=n;i++) calc(i,1);
    else{                  
        for(int i=1;i<10000;i++) calc(i,1);
        for(int i=1;i<n/10000%10000;i++) calc(i,10000);
        for(int i=1;i<n/(int)(1e8);i++) calc(i,(int)(1e8));
        for(int i=0;i<10;i++) a[i]+=4000*(n/10000-1);
        for(int i=n/10000*10000;i<=n;i++) calc(i,1);
    }                
    
    cin>>m;
    if(m<10000) for(int i=1;i<=m;i++) calc2(i,1);
    else{                  
        for(int i=1;i<10000;i++) calc2(i,1);
        for(int i=1;i<m/10000%10000;i++) calc2(i,10000); 
        for(int i=1;i<m/(int)(1e8);i++) calc2(i,(int)(1e8));
        for(int i=0;i<10;i++) b[i]+=4000*(m/10000-1);
        for(int i=m/10000*10000;i<=m;i++) calc2(i,1);
    }   
	calc2(n,1);
    for(int i=0;i<=9;i++) cout<<b[i]-a[i]<<" ";
    return 0;
}
2025/7/20 12:11
加载中...