#include <iostream>
#include <string>
#include <cmath>
using namespace std;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(NULL);
long long a, b, sum = 0,pom;
string liczba;
int flag = 0;
cin >> a >> b;
pom = a;
while (pom <= b)
{
liczba = to_string(pom);
for (int i = 0; i < liczba.size(); i++)
{
int dzielnik = liczba[i] - '0';
if (dzielnik == 0)
{
long long dod= pow(10, (liczba.size() - i - 1));
pom += dod;
flag = 2;
break;
}
else
{
if (pom % dzielnik != 0)
{
flag = 1;
}
}
}
if (flag == 0)
{
sum++;
pom++;
}
else if (flag == 1)
{
pom++;
flag = 0;
}
else flag = 0;
}
cout << sum;
return 0;
}
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 | #include <iostream> #include <string> #include <cmath> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); long long a, b, sum = 0,pom; string liczba; int flag = 0; cin >> a >> b; pom = a; while (pom <= b) { liczba = to_string(pom); for (int i = 0; i < liczba.size(); i++) { int dzielnik = liczba[i] - '0'; if (dzielnik == 0) { long long dod= pow(10, (liczba.size() - i - 1)); pom += dod; flag = 2; break; } else { if (pom % dzielnik != 0) { flag = 1; } } } if (flag == 0) { sum++; pom++; } else if (flag == 1) { pom++; flag = 0; } else flag = 0; } cout << sum; return 0; } |
English