#include <iostream>
#include <sstream>
using namespace std;
bool czy_pot(int liczba){
string przeliczana;{
ostringstream tymczasowe;
tymczasowe << liczba;
przeliczana=tymczasowe.str();
}
int n=przeliczana.size() - 1;
while(n>=0){
if(przeliczana[n]=='0' || liczba%(przeliczana[n] - 48)) return 0;
n--;
}
return 1;
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
unsigned long long l,r,n=0;
cin >> l >> r;
while (l<=r){
if(czy_pot(l)==1) n++;
l++;
if(l%10==0) l++;
}
cout << 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 | #include <iostream> #include <sstream> using namespace std; bool czy_pot(int liczba){ string przeliczana;{ ostringstream tymczasowe; tymczasowe << liczba; przeliczana=tymczasowe.str(); } int n=przeliczana.size() - 1; while(n>=0){ if(przeliczana[n]=='0' || liczba%(przeliczana[n] - 48)) return 0; n--; } return 1; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); unsigned long long l,r,n=0; cin >> l >> r; while (l<=r){ if(czy_pot(l)==1) n++; l++; if(l%10==0) l++; } cout << n; return 0; } |
English