Untitled
ducsieumanh1hitlanamguku
plain_text
23 days ago
586 B
3
Indexable
Never
#include <bits/stdc++.h> using namespace std; int a,b; int mu(int a,int b) { int x=1; for (int i=1;i<=b;i++) x*=a; return x; } int cal(int c,int base,int n) {//so chu so c o hang base tu 1-x int x=n; x/=mu(10,base-1); int y=0; if (x%10>=c) y++; return (n/mu(10,base))+y; } int tinh(int cs,int n) { int base=1,sum=0; while (mu(10,base)<=n+1) { sum+=cal(cs,base,n); base++; } return sum; //5 } int main() { while (cin>>a>>b) { if (a==0&&b==0) break; for (int i=0;i<=9;i++) { cout<<tinh(i,b)-tinh(i,a)+1<<" "; } cout<<endl; } }
Leave a Comment