#include <iostream>
#include<cmath>
using namespace std;
int main()
{
unsigned long long int l, r, i, counter = 0, pom;
int j, reszta;
bool potyczkowa;
cin>>l>>r;
for (i = l; i <= r; i++)
{
int tab[10] = {0};
potyczkowa = true;
if (i < 10) counter++;
else
{
pom = i;
while (pom > 0)
{
reszta = pom % 10;
if (reszta == 0 || (tab[reszta] == 0 && i % reszta != 0))
{
potyczkowa = false;
break;
}
tab[reszta]++;
pom /= 10;
}
if (potyczkowa) counter++;
}
}
cout<<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 26 27 28 29 30 31 32 33 34 35 | #include <iostream> #include<cmath> using namespace std; int main() { unsigned long long int l, r, i, counter = 0, pom; int j, reszta; bool potyczkowa; cin>>l>>r; for (i = l; i <= r; i++) { int tab[10] = {0}; potyczkowa = true; if (i < 10) counter++; else { pom = i; while (pom > 0) { reszta = pom % 10; if (reszta == 0 || (tab[reszta] == 0 && i % reszta != 0)) { potyczkowa = false; break; } tab[reszta]++; pom /= 10; } if (potyczkowa) counter++; } } cout<<counter; return 0; } |
English