#include <iostream> using namespace std; unsigned long long potyczkowa (unsigned long long a, unsigned long long b) { ios_base::sync_with_stdio(0); long long c=0; while (b!=0) { if (b%10==0) { c++; break; } else if(b!=1) { if(a%(b%10)!=0) { c++; break; } } b=b/10; } return c; } int main() { ios_base::sync_with_stdio(0); unsigned long long r, l, d=0; cin>>r>>l; while(r<l) { if(potyczkowa(r, r)==0) d++; r++; } cout<<d; 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 37 38 39 40 41 | #include <iostream> using namespace std; unsigned long long potyczkowa (unsigned long long a, unsigned long long b) { ios_base::sync_with_stdio(0); long long c=0; while (b!=0) { if (b%10==0) { c++; break; } else if(b!=1) { if(a%(b%10)!=0) { c++; break; } } b=b/10; } return c; } int main() { ios_base::sync_with_stdio(0); unsigned long long r, l, d=0; cin>>r>>l; while(r<l) { if(potyczkowa(r, r)==0) d++; r++; } cout<<d; return 0; } |