1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <iostream>
#include <string>

int main()
{
    unsigned long long int iOverallCounter = 0;
    unsigned long long int iInputNumber1 = 0;
    unsigned long long int iInputNumber2 = 0;
    std::string oTempNumberString;
    long long int iMaxPowerTo = 0;
    unsigned long long int iCounterIndexNumber = 0;
    bool IsSkirmishNumber = false;
    unsigned long long int iDecimalPart = 0;
    bool bGetNumbers = false;

    std::cin >> iInputNumber1;
    std::cin >> iInputNumber2;

    if( iInputNumber1 > iInputNumber2 )
    {
        return 0;
    }

    for(unsigned long long int iRangeNumber = iInputNumber1;
        iRangeNumber <= iInputNumber2; iRangeNumber++)
    {
        IsSkirmishNumber = true;
        iCounterIndexNumber = 0;
        oTempNumberString = std::to_string( iRangeNumber );
        iMaxPowerTo = oTempNumberString.length() - 1;

        while (iMaxPowerTo >= 0)
        {
            iDecimalPart = (unsigned long long int)(oTempNumberString[iCounterIndexNumber] - '0');

            if (iDecimalPart == 0
                || (iDecimalPart != 0
                    && iRangeNumber % iDecimalPart != 0))
            {
                IsSkirmishNumber = false;
                break;
            }

            iCounterIndexNumber++;
            iMaxPowerTo--;
        }

        if( IsSkirmishNumber )
        {
            iOverallCounter++;
        }
    }

    std::cout << iOverallCounter;

    system("PAUSE");

    return 0;
}