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