#include <iostream> #include <string> using namespace std; bool t(size_t l) { string temp = to_string(l); for(size_t i=0;i<temp.size();i++) { int c = temp[i] - '0'; if(c == 0 || l % c != 0) return false; } return true; } int main() { size_t l, r; cin >> l >> r; size_t counter=0; for(size_t i = l;i<=r;i++) if(t(i)) counter++; cout << counter; 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 | #include <iostream> #include <string> using namespace std; bool t(size_t l) { string temp = to_string(l); for(size_t i=0;i<temp.size();i++) { int c = temp[i] - '0'; if(c == 0 || l % c != 0) return false; } return true; } int main() { size_t l, r; cin >> l >> r; size_t counter=0; for(size_t i = l;i<=r;i++) if(t(i)) counter++; cout << counter; return 0; } |