fork(1) download
  1. #include <bits/stdc++.h>
  2. #define ull unsigned long long
  3.  
  4. using namespace std;
  5.  
  6. ull a, b, ile = 0;
  7.  
  8. bool prim(ull x) {
  9. for (ull i = 2; i * i <= x; i ++)
  10. if (x % i == 0)
  11. return 0;
  12. return 1;
  13. }
  14.  
  15. void rekDokl(ull x) {
  16. if (x > b or !prim(x))
  17. return;
  18. if (prim(x) and x >= a)
  19. ile ++;
  20.  
  21. rekDokl(x * 10 + 1);
  22. rekDokl(x * 10 + 3);
  23. rekDokl(x * 10 + 7);
  24. rekDokl(x * 10 + 9);
  25. }
  26.  
  27. int main() {
  28. ios_base::sync_with_stdio(0);
  29. cin.tie(0); cout.tie(0);
  30. cin >> a >> b;
  31.  
  32. rekDokl(2);
  33. rekDokl(3);
  34. rekDokl(5);
  35. rekDokl(7);
  36.  
  37. cout << ile;
  38. }
Success #stdin #stdout 0.01s 5536KB
stdin
1 1000000000000000000
stdout
83