#include <bits/stdc++.h> using namespace std; typedef long long LL; bool is_pot_num(LL x) { LL y = x; while (x > 0) { LL d = x % 10; x /= 10; if (d == 0 || y % d != 0) return false; } return true; } int main() { ios::sync_with_stdio(false); cin.tie(0); LL l, r; cin >> l >> r; LL c = 0; for (LL i = l; i <= r; ++i) { if (is_pot_num(i)) { // cerr << i << "\n"; c++; } } cout << c << endl; 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 36 37 38 39 40 41 42 43 | #include <bits/stdc++.h> using namespace std; typedef long long LL; bool is_pot_num(LL x) { LL y = x; while (x > 0) { LL d = x % 10; x /= 10; if (d == 0 || y % d != 0) return false; } return true; } int main() { ios::sync_with_stdio(false); cin.tie(0); LL l, r; cin >> l >> r; LL c = 0; for (LL i = l; i <= r; ++i) { if (is_pot_num(i)) { // cerr << i << "\n"; c++; } } cout << c << endl; return 0; } |