#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll potyczka(ll n){
ll temp=n;
while(temp){
ll t=temp%10;
if(t==0) return 0;
if(n%t>0) return 0;
temp/=10;
}
return 1;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
ll l,r,wynik=0;
ll i;
cin>>l>>r;
for(ll i=l;i<=r;++i)
if(potyczka(i)) ++wynik;
cout<<wynik<<"\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 28 | #include<bits/stdc++.h> using namespace std; typedef long long int ll; ll potyczka(ll n){ ll temp=n; while(temp){ ll t=temp%10; if(t==0) return 0; if(n%t>0) return 0; temp/=10; } return 1; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ll l,r,wynik=0; ll i; cin>>l>>r; for(ll i=l;i<=r;++i) if(potyczka(i)) ++wynik; cout<<wynik<<"\n"; return 0; } |
English