本文共 534 字,大约阅读时间需要 1 分钟。
传送门:
#include #include #include #include #include #include #include #include using namespace std;int a[10]={0};void deal(int n,int value){ if(n<=0) return; int one,ten; one = n%10; n/=10; ten=n; for (int i=0; i<=one; ++i) {//个位上出现的数统计下来 a[i]+=value; } while (ten) { a[ten%10]+= (one+1)*value; ten/=10; } for (int i=0; i<10; ++i) { a[i]+=value*n; } a[0]-=value;//第一位是0的情况排除. deal(n-1,value*10);}int main(){ int n; scanf("%d",&n); deal(n,1); printf("%d\n",a[1]); return 0;}
转载地址:http://mqhji.baihongyu.com/