#include <cstdio> int main(){ long long l, r, counter =0; scanf(" %lld %lld ",&l,&r); for(long long i=l; i<=r; i++){ long long buf = i; bool potyczkov = true; if(( i%10LL == 0)||(i%( i%10LL )!=0)) potyczkov = false; while(buf>=10LL){ buf/=10LL; if((buf %10LL == 0)||( i % (buf %10LL ) != 0)){ potyczkov = false; break; } } if (potyczkov) { //printf("%I64d\n",i); counter++; } } printf("%lld\n",counter); 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 | #include <cstdio> int main(){ long long l, r, counter =0; scanf(" %lld %lld ",&l,&r); for(long long i=l; i<=r; i++){ long long buf = i; bool potyczkov = true; if(( i%10LL == 0)||(i%( i%10LL )!=0)) potyczkov = false; while(buf>=10LL){ buf/=10LL; if((buf %10LL == 0)||( i % (buf %10LL ) != 0)){ potyczkov = false; break; } } if (potyczkov) { //printf("%I64d\n",i); counter++; } } printf("%lld\n",counter); return 0; } |