fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. bool potyczkowa(long long x) {
  6. long long y = x;
  7.  
  8. while (y) {
  9. if (y % 10 == 0)
  10. return 0;
  11. else if (x % (y % 10))
  12. return 0;
  13. y /= 10;
  14. }
  15.  
  16. return 1;
  17. }
  18.  
  19. int main() {
  20. long long l, r, ile = 0;
  21. cin >> l >> r;
  22.  
  23. for (int i = l; i <= r; i ++)
  24. if (potyczkowa(i))
  25. ile ++;
  26.  
  27. cout << ile;
  28. }
Success #stdin #stdout 0.01s 5512KB
stdin
1 100
stdout
23