洛谷P1554 梦中的统计 题解

题目传送门

这道题暴力又让我过了。。。数据真的很水(luogu

暴力枚举n~m的每个数,再统计一次,交付评测。。。AC

#include<bits/stdc++.h>
using namespace std;
int n,m,a[15];
int main(){
    scanf("%d%d",&n,&m);
    for(int i=n;i<=m;i++){
        int tmp=i,k=0,fs;
        while(tmp!=0){
            ++k;
            fs=tmp%10;
            tmp/=10;
            a[fs]++;
        }
    }
    for(int i=0;i<=9;i++) printf("%d ",a[i]);
    puts("");return 0;
}

猜你喜欢

转载自www.cnblogs.com/yzx1798106406/p/9038050.html