#include<cstdio> bool isPotyczkow(long long int a) { long long int temp = a; while (temp != 0) { //printf("temp = %lld\n", temp); if (temp % 10 == 0 || a % (temp % 10) != 0) { return false; } temp /= 10; } return true; } int main() { long long int l, r; (void)! scanf("%lld %lld", &l, &r); long long result = 0; for(long long int i = l; i <= r; i++) { //printf("x %lld\n", i); if (isPotyczkow(i)){ // printf("True\n"); result++; } } printf("%lld\n", result); 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 | #include<cstdio> bool isPotyczkow(long long int a) { long long int temp = a; while (temp != 0) { //printf("temp = %lld\n", temp); if (temp % 10 == 0 || a % (temp % 10) != 0) { return false; } temp /= 10; } return true; } int main() { long long int l, r; (void)! scanf("%lld %lld", &l, &r); long long result = 0; for(long long int i = l; i <= r; i++) { //printf("x %lld\n", i); if (isPotyczkow(i)){ // printf("True\n"); result++; } } printf("%lld\n", result); return 0; } |