#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
long long int poczatek, koniec, ile=0, j;
string si;
cin >> poczatek >> koniec;
for (long long int i=poczatek; i <= koniec; i++) {
si = to_string(i);
for (j=si.size() - 1; j >= 0; j--) {
if (si[j] == '0' || i % (si[j] - '0') != 0)
break;
}
if (j == -1)
ile++;
}
cout << ile;
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 | #include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); long long int poczatek, koniec, ile=0, j; string si; cin >> poczatek >> koniec; for (long long int i=poczatek; i <= koniec; i++) { si = to_string(i); for (j=si.size() - 1; j >= 0; j--) { if (si[j] == '0' || i % (si[j] - '0') != 0) break; } if (j == -1) ile++; } cout << ile; return 0; } |
English