#include <iostream> using namespace std; int main() { long long int a,b,i1,r,wynik=0; cin>>a>>b; for (long long int i=a;i<=b;i++) { i1=i; while (i1>0) { r=i1%10; i1=i1/10; if(r==0) { i1=-1; } else if (i%r!=0) { i1=-1; } } if (i1==0) { 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 | #include <iostream> using namespace std; int main() { long long int a,b,i1,r,wynik=0; cin>>a>>b; for (long long int i=a;i<=b;i++) { i1=i; while (i1>0) { r=i1%10; i1=i1/10; if(r==0) { i1=-1; } else if (i%r!=0) { i1=-1; } } if (i1==0) { wynik++; } } cout<<wynik; return 0; } |