AcWing 338. Counting Problems

#include <the iostream> 
#include <algorithm> 
#include <Vector> the using namespace STD; const int N = 10 ; / * 
001 ~. 1-ABC, 999 
abcxegf 
    1. NUM [I] <X, 0 
    2. NUM [I ] == X, 0 ~ EFG 
    3. NUM [I]> X, 0 ~ 999 * / int GET (Vector < int > NUM, int L, int R & lt) { // find the front of the numbers of these bits is the number int = RES 0 ;
     for ( int I = L; I> = R & lt; I -) RES = RES * 10 +

 

 







 
    NUM [i];
     return RES; 
} 

int power10 ( int X) { // find the i th 10 
    int RES = . 1 ;
     the while (X -) * RES = 10 ;
     return RES; 
} 

int COUNT ( int n-, int x) { // . 1 to which n, x number appears 
    IF (n)! return  0 ; 
    Vector < int > NUM; // every 
    the while (n) { 
        num.push_back (n % 10 ); 
        n/ = 10 ; 
    } 
    n- = num.size ();
     int RES = 0 ;
     for ( int I = n-- . 1 - X;! I> = 0 ; I - ) {
         // determines whether the most significant bit in the enumeration 
        IF (I <n-- . 1 ) {
             //             I in front of all these bits 
            RES + = GET (NUM, n-- . 1 , I + . 1 ) * power10 (I);
             IF (! X) RES - = power10 (I) ; 
        } 
        IF (NUM [I] == X) = RES +get(num, i - 1, 0) + 1;
        else if (num[i] > x) res += power10(i);
    }

    return res;
}

int main() {
    int a, b;
    while (cin >> a >> b , a) {
        if (a > b) swap(a, b);

        for (int i = 0; i <= 9; i ++ )
            cout << count(b, i) - count(a - 1, i) << ' ';
        cout << endl;
    }

    return 0;
}

 

Guess you like

Origin www.cnblogs.com/QingyuYYYYY/p/11909443.html