#include <iostream>
using namespace std;
bool check(long long n) {
long long nn=n;
if(n==0) return false;
while(n!=0) {
int d = n%10;
if(d==0 || nn%d!=0) return false;
n/=10;
}
return true;
}
int main() {
long long l, r;
cin>> l >> r;
long long res=0;
for(long long i=l; i<=r; ++i)
if(check(i)) ++res;
cout << res << 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 | #include <iostream> using namespace std; bool check(long long n) { long long nn=n; if(n==0) return false; while(n!=0) { int d = n%10; if(d==0 || nn%d!=0) return false; n/=10; } return true; } int main() { long long l, r; cin>> l >> r; long long res=0; for(long long i=l; i<=r; ++i) if(check(i)) ++res; cout << res << endl; return 0; } |
English