Loading

洛谷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;
}
posted @ 2018-05-14 20:46  yzx_1798106406  阅读(224)  评论(0编辑  收藏  举报