#include <iostream>
using namespace std;
bool liczba_potyczkowa (long long a)
{
if (a%10==0) return false;
long long b=a;
while (b>0)
{
if (b%10==0) return false;
if (a%(b%10)!=0) return false;
b/=10;
}
return true;
}
int main()
{
ios_base::sync_with_stdio(0);
long long a, b, x=0;
cin>>a>>b;
for (long long i=a;i<=b;++i)
if (liczba_potyczkowa(i)==1) x++;
cout<<x;
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 | #include <iostream> using namespace std; bool liczba_potyczkowa (long long a) { if (a%10==0) return false; long long b=a; while (b>0) { if (b%10==0) return false; if (a%(b%10)!=0) return false; b/=10; } return true; } int main() { ios_base::sync_with_stdio(0); long long a, b, x=0; cin>>a>>b; for (long long i=a;i<=b;++i) if (liczba_potyczkowa(i)==1) x++; cout<<x; return 0; } |
English