fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int nfull[1000009]={0};
  4. void pre()
  5. {
  6. for(long i=2;i<=100000;i++)
  7. {
  8. long temp=i,count=0;
  9. if(temp%2==0)
  10. {
  11. count++;
  12. while(temp%2==0)
  13. temp/=2;
  14. }
  15. for(long j=3;j<=sqrt(i);j+=2)
  16. {
  17. if(temp%j==0)
  18. {
  19. count++;
  20. while(temp%j==0)
  21. temp/=j;
  22. }
  23. }
  24. if(temp>2)
  25. count++;
  26. nfull[i]=count;
  27. }
  28. }
  29. int main() {
  30. // your code goes here
  31. pre();
  32. long long int t;
  33. nfull[1]=0;
  34. scanf("%lld",&t);
  35. while(t--)
  36. {
  37. long long int a,b,n,count=0;
  38. scanf("%lld%lld%lld",&a,&b,&n);
  39. for(long long int i=a;i<=b;++i)
  40. {
  41. if(nfull[i]==n)
  42. count++;
  43. }
  44. printf("%lld\n",count);
  45. }
  46. return 0;
  47. }
Success #stdin #stdout 0.2s 7004KB
stdin
5
1 3 1
1 10 2
1 10 3
1 100 3
1 1000 0
stdout
2
2
0
8
1