#include <stdio.h> bool inline is_valid(long long number) { long long n = number; while(n > 0) { char digit = n % 10; if (digit == 0) return false; if (number % digit != 0) return false; n /= 10; } return true; } int main() { long long l, r; scanf("%lld %lld", &l, &r); int count = 0; for (long long i = l; i <= r; ++i) { if(is_valid(i)) count++; } printf("%d\n", count); }
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 | #include <stdio.h> bool inline is_valid(long long number) { long long n = number; while(n > 0) { char digit = n % 10; if (digit == 0) return false; if (number % digit != 0) return false; n /= 10; } return true; } int main() { long long l, r; scanf("%lld %lld", &l, &r); int count = 0; for (long long i = l; i <= r; ++i) { if(is_valid(i)) count++; } printf("%d\n", count); } |