#include <iostream> bool lp(long long a){ long long t = a; while(t > 0){ if(t % 10 == 0) return false; if(a % (t%10) != 0) return false; t = t/10; } return true; } int main() { long long a, b; std::cin >> a; std::cin >> b; long long w = 0; for (long long i = a; i <= b; ++i) { if(lp(i)) w++; } std::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 26 27 28 | #include <iostream> bool lp(long long a){ long long t = a; while(t > 0){ if(t % 10 == 0) return false; if(a % (t%10) != 0) return false; t = t/10; } return true; } int main() { long long a, b; std::cin >> a; std::cin >> b; long long w = 0; for (long long i = a; i <= b; ++i) { if(lp(i)) w++; } std::cout << w; return 0; } |