#include <cstdio> #define lld long long int bool check(lld x) { int temp = x; while(temp > 0) { if(temp % 10 == 0) return false; if(x % (temp % 10) != 0) { return false; } temp /= 10; } return true; } int main() { lld l, r, out = 0; scanf("%lld%lld", &l, &r); for(lld i = l; i <= r; i++) if(check(i)) out++; printf("%lld", out); }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | #include <cstdio> #define lld long long int bool check(lld x) { int temp = x; while(temp > 0) { if(temp % 10 == 0) return false; if(x % (temp % 10) != 0) { return false; } temp /= 10; } return true; } int main() { lld l, r, out = 0; scanf("%lld%lld", &l, &r); for(lld i = l; i <= r; i++) if(check(i)) out++; printf("%lld", out); } |