#include<bits/stdc++.h> using namespace std; bool f(long long n){ long long a = n; while(a > 0){ if(a % 10 == 0) return 0; if(n % (a % 10) != 0) return 0; a /= 10; } return 1; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long l, r, s = 0; cin >> l >> r; while(l <= r) s += f(l++); cout << s; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | #include<bits/stdc++.h> using namespace std; bool f(long long n){ long long a = n; while(a > 0){ if(a % 10 == 0) return 0; if(n % (a % 10) != 0) return 0; a /= 10; } return 1; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long l, r, s = 0; cin >> l >> r; while(l <= r) s += f(l++); cout << s; } |