#include <bits/stdc++.h>
using namespace std;
bool is_potyczkowa(long long n){
long long div = 1, copy_num = n;
while (copy_num > 0){
div = copy_num % 10;
copy_num /= 10;
if (div == 0 || n % div != 0)
return false;
}
return true;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(NULL);
long long beg, end, count = 0;
cin >> beg >> end;
for (; beg <= end; beg++){
count += (long long)(is_potyczkowa(beg));
}
cout << count << "\n";
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 | #include <bits/stdc++.h> using namespace std; bool is_potyczkowa(long long n){ long long div = 1, copy_num = n; while (copy_num > 0){ div = copy_num % 10; copy_num /= 10; if (div == 0 || n % div != 0) return false; } return true; } int main(){ ios_base::sync_with_stdio(0); cin.tie(NULL); long long beg, end, count = 0; cin >> beg >> end; for (; beg <= end; beg++){ count += (long long)(is_potyczkowa(beg)); } cout << count << "\n"; return 0; } |
English