#include <iostream>
int main() {
int lower_bound;
int upper_bound;
std::cin >> lower_bound;
std::cin >> upper_bound;
int count = 0;
int number = 0;
bool isPotyczkowNumber = true;
for(int i = 1; i <= upper_bound; i++) {
number = i;
isPotyczkowNumber = true;
while (number > 0) {
if (number % 10 == 0 || i % (number % 10) != 0) {
isPotyczkowNumber = false;
break;
} else {
number = number / 10;
}
}
if (isPotyczkowNumber)
count++;
}
std::cout << count << std::endl;
}
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 | #include <iostream> int main() { int lower_bound; int upper_bound; std::cin >> lower_bound; std::cin >> upper_bound; int count = 0; int number = 0; bool isPotyczkowNumber = true; for(int i = 1; i <= upper_bound; i++) { number = i; isPotyczkowNumber = true; while (number > 0) { if (number % 10 == 0 || i % (number % 10) != 0) { isPotyczkowNumber = false; break; } else { number = number / 10; } } if (isPotyczkowNumber) count++; } std::cout << count << std::endl; } |
English