#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long l,r, wynik=0; cin>>l>>r; //cout<<l<<r; for (long long item=l; item<=r; item++){ long long n = item; //cout<<"\n"<<n<<" "; bool tak = 1; while(n!=0){ long long d = n%10; if(d==0){ tak = 0; } n=n/10; //cout<<n<<" "; if(tak and item%d!=0LL){ tak=0; } } if(tak){ wynik++; } } cout<<wynik; 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 29 30 31 32 33 34 | #include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long l,r, wynik=0; cin>>l>>r; //cout<<l<<r; for (long long item=l; item<=r; item++){ long long n = item; //cout<<"\n"<<n<<" "; bool tak = 1; while(n!=0){ long long d = n%10; if(d==0){ tak = 0; } n=n/10; //cout<<n<<" "; if(tak and item%d!=0LL){ tak=0; } } if(tak){ wynik++; } } cout<<wynik; return 0; } |