fork download
  1. #include<bits/stdc++.h>
  2. #define ll long long
  3. using namespace std;
  4. ll a,b,t,d[1000006];
  5. int main()
  6. {
  7. ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  8. freopen("SBD.inp", "r", stdin);
  9. freopen("SBD.out", "w", stdout);
  10. memset(d,0,sizeof d);
  11. for(int i = 1; i <= 1000000; i++)
  12. {
  13. d[i] = d[i-1];
  14. if(i%3 == 0)
  15. {
  16. ll t = i,uc = 1;
  17. for(int j = 2; j <= sqrt(t) ;j++)
  18. {
  19. if(t%j == 0)
  20. {
  21. ll dem = 0;
  22. while(t%j == 0)
  23. {
  24. dem++;
  25. t/=j;
  26. }
  27. uc = uc*(dem+1);
  28. }
  29. }
  30. if(t > 1)
  31. uc*=2;
  32. if(uc == 9)
  33. d[i]++;
  34. }
  35. }
  36. cin >> t;
  37. while(t--)
  38. {
  39. cin >> a >> b;
  40. cout << d[b] - d[a-1] << '\n';
  41. }
  42. }
  43.  
Success #stdin #stdout 0.59s 11712KB
stdin
Standard input is empty
stdout
Standard output is empty