#include <iostream> using namespace std; int main() { unsigned long long l, r; cin >> l >> r; unsigned long long s = 0; while (l <= r) { int i = l % 10; unsigned long long n = 10; while (true) { if (i == 0 || l % i != 0) { break; } if (n > l) { s++; break; } i = l / n % 10; n *= 10; } l++; } cout << s; 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 | #include <iostream> using namespace std; int main() { unsigned long long l, r; cin >> l >> r; unsigned long long s = 0; while (l <= r) { int i = l % 10; unsigned long long n = 10; while (true) { if (i == 0 || l % i != 0) { break; } if (n > l) { s++; break; } i = l / n % 10; n *= 10; } l++; } cout << s; return 0; } |