#include <iostream> using namespace std; bool Patyk(unsigned long long x) { unsigned long long y = x; int r=0; while(y>0) { r = y%10; if(r!=0) { if(x%r!=0) return false; } else { return false; } y/=10; } return true; } int main() { ios_base::sync_with_stdio(false); cout.tie(0); cin.tie(0); unsigned long long minimum, maximum; long long wynik=0; cin>>minimum>>maximum; for(unsigned long long i=minimum; i<=maximum; ++i) { if(Patyk(i) == true) 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 29 30 31 32 33 34 35 36 | #include <iostream> using namespace std; bool Patyk(unsigned long long x) { unsigned long long y = x; int r=0; while(y>0) { r = y%10; if(r!=0) { if(x%r!=0) return false; } else { return false; } y/=10; } return true; } int main() { ios_base::sync_with_stdio(false); cout.tie(0); cin.tie(0); unsigned long long minimum, maximum; long long wynik=0; cin>>minimum>>maximum; for(unsigned long long i=minimum; i<=maximum; ++i) { if(Patyk(i) == true) wynik++; } cout<<wynik<<'\n'; return 0; } |