#include <iostream>
using namespace std;
bool potyczkowa(long long n){
bool tab[10]= {}; //tabica cyfr
long long N=n;
while(n>0){
tab[n%10]=true;
n = n/10;
}
if (tab[0]) //jest zero
return false;
for (int i=2; i<10; i++)
if (tab[i] and N%i!=0)
return false;
return true;
}
int main()
{
long long l, r;
cin >> l>> r;
long long counter =0;
for(long long i=l; i<=r; i++){
if (potyczkowa(i))
counter++;
}
cout << counter <<endl;
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 | #include <iostream> using namespace std; bool potyczkowa(long long n){ bool tab[10]= {}; //tabica cyfr long long N=n; while(n>0){ tab[n%10]=true; n = n/10; } if (tab[0]) //jest zero return false; for (int i=2; i<10; i++) if (tab[i] and N%i!=0) return false; return true; } int main() { long long l, r; cin >> l>> r; long long counter =0; for(long long i=l; i<=r; i++){ if (potyczkowa(i)) counter++; } cout << counter <<endl; return 0; } |
English