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