#include <iostream> bool isPotyczkovNumber(const long long& number) { long long copy = number; while (copy > 0) { if ((copy % 10) == 0 || (number % (copy % 10)) != 0) return false; copy /= 10; } return true; } void potyczkov() { long long l = 1; long long r = 1; long sum = 0; std::cin >> l; std::cin >> r; for (long long i = l; i < r; i++) { if (isPotyczkovNumber(i)) sum++; } std::cout << sum; } int main() { potyczkov(); 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 | #include <iostream> bool isPotyczkovNumber(const long long& number) { long long copy = number; while (copy > 0) { if ((copy % 10) == 0 || (number % (copy % 10)) != 0) return false; copy /= 10; } return true; } void potyczkov() { long long l = 1; long long r = 1; long sum = 0; std::cin >> l; std::cin >> r; for (long long i = l; i < r; i++) { if (isPotyczkovNumber(i)) sum++; } std::cout << sum; } int main() { potyczkov(); return 0; } |