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
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
#include<iostream>
using namespace std;
int main()
{
    int p,k,r=0;
    cin>>p;
    cin>>k;
    for(int i=p; i<=k; i++)
    {
        if(i<10)
        {
            r++;
            continue;
        }
        if(i<100)
        {
            if(i%10==0)
            {
                continue;
            }
            else
            {
                if(i%(i%10)==0 && i%((i-(i%10) )/10)==0 )
                {
                    r++;
                    continue;
                }
            }
        }
        if(i<1000)
        {
            if(i%10==0||((i%100)-(i%10))/10==0)
            {
                continue;
            }
            else
            {
                if(i%(i%10)==0&&i%(((i%100)-(i%10))/10)==0&&i%(((i%1000)-(i%100))/100)==0)
                {
                    r++;
                    continue;
                }

            }
        }
        if(i<10000)
        {
            if(i%10==0||((i%100)-(i%10))/10==0||((i%1000)-(i%100))==0)
            {
                continue;
            }
            if(i%(i%10)==0&&i%(((i%100)-(i%10))/10)==0&&i%(((i%1000)-(i%100))/100)==0&&i%(((i%10000)-(i%1000))/1000)==0)
            {
                r++;
                continue;
            }

        }
        if(i<100000)
        {
            if(i%10==0||((i%100)-(i%10))/10==0||((i%1000)-(i%100))==0||((i%10000)-(i%1000))==0)
            {
                continue;
            }
            if(i%(i%10)==0&&i%(((i%100)-(i%10))/10)==0&&i%(((i%1000)-(i%100))/100)==0&&i%(((i%10000)-(i%1000))/1000)==0&&i%(((i%100000)-(i%10000))/10000)==0)
            {
                r++;
                continue;
            }

        }
        if(i<1000000)
        {
            if(i%10==0||((i%100)-(i%10))/10==0||((i%1000)-(i%100))==0||((i%10000)-(i%1000))==0||((i%100000)-(i%10000))==0)
            {
                continue;
            }
            if(i%(i%10)==0&&i%(((i%100)-(i%10))/10)==0&&i%(((i%1000)-(i%100))/100)==0&&i%(((i%10000)-(i%1000))/1000)==0&&i%(((i%100000)-(i%10000))/10000)==0&&i%(((i%1000000)-(i%100000))/100000)==0)
            {
                r++;
                continue;
            }

        }
        if(i<10000000)
        {
            if(i%10==0||((i%100)-(i%10))/10==0||((i%1000)-(i%100))==0||((i%10000)-(i%1000))==0||((i%100000)-(i%10000))==0||((i%1000000)-(i%100000))==0)
            {
                continue;
            }
            if(i%(i%10)==0&&i%(((i%100)-(i%10))/10)==0&&i%(((i%1000)-(i%100))/100)==0&&i%(((i%10000)-(i%1000))/1000)==0&&i%(((i%100000)-(i%10000))/10000)==0&&i%(((i%1000000)-(i%100000))/100000)==0&&i%(((i%10000000)-(i%1000000))/1000000))
            {
                r++;
                continue;
            }
        }
        if(i<100000000)
        {
            if(i%10==0||((i%100)-(i%10))/10==0||((i%1000)-(i%100))==0||((i%10000)-(i%1000))==0||((i%100000)-(i%10000))==0||((i%1000000)-(i%100000))==0||((i%10000000)-(i%1000000))==0)
            {
                continue;
            }
            if(i%(i%10)==0&&i%(((i%100)-(i%10))/10)==0&&i%(((i%1000)-(i%100))/100)==0&&i%(((i%10000)-(i%1000))/1000)==0&&i%(((i%100000)-(i%10000))/10000)==0&&i%(((i%1000000)-(i%100000))/100000)==0&&i%(((i%100000000)-(i%10000000))/10000000))
            {
                r++;
                continue;
            }

        }
    }
    cout<<r;
}