#include<bits/stdc++.h> #define ff first #define ss second #define mp make_pair #define pb push_back using namespace std; typedef long long ll; ll dp[19][10][48][5][7][8][9]; //length, first, mask, mod inline bool isp(ll x) { ll c=x; while(c) { if(c%10==0) return 0; if(x%(c%10)) return 0; c/=10; } return 1; } ll l,r,w; int main() { scanf("%lld%lld",&l,&r); for(ll i=l;i<=r;++i) { if(isp(i)) { ++w; // printf("%lld\n",i); } } printf("%lld\n",w); }
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> #define ff first #define ss second #define mp make_pair #define pb push_back using namespace std; typedef long long ll; ll dp[19][10][48][5][7][8][9]; //length, first, mask, mod inline bool isp(ll x) { ll c=x; while(c) { if(c%10==0) return 0; if(x%(c%10)) return 0; c/=10; } return 1; } ll l,r,w; int main() { scanf("%lld%lld",&l,&r); for(ll i=l;i<=r;++i) { if(isp(i)) { ++w; // printf("%lld\n",i); } } printf("%lld\n",w); } |