#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
bool spr(ll a)
{
string b=to_string(a);
for(int i=0; i<b.size(); i++)
if(b[i] == '0' || a%(b[i]-'0') != 0)
return false;
return true;
}
int main()
{
ll a,b;
cin >> a >> b;
ll wynik=0;
for(ll i=a; i<=b; i++)
if(spr(i))
wynik++;
cout << wynik << "\n";
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | #include <bits/stdc++.h> using namespace std; typedef long long ll; bool spr(ll a) { string b=to_string(a); for(int i=0; i<b.size(); i++) if(b[i] == '0' || a%(b[i]-'0') != 0) return false; return true; } int main() { ll a,b; cin >> a >> b; ll wynik=0; for(ll i=a; i<=b; i++) if(spr(i)) wynik++; cout << wynik << "\n"; } |
English