fork(1) download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. #define MAX 10005
  5. #define MAX1 100005
  6.  
  7. int main()
  8. {
  9. ll a,b,n;
  10. cin>>a>>b>>n;
  11. ll count=0;
  12. ll div[MAX];
  13. bool prime[MAX1];
  14. //memset(div,2,sizeof(div));
  15. for(ll i=0; i<=(b-a+2); i++)
  16. div[i]=2;
  17. memset(prime,true,sizeof(prime));
  18. clock_t start,end;
  19. start=clock();
  20. for(ll p=2; p*p<=b; p++)
  21. {
  22. for(ll i=p*2; i<=b; i+=p)
  23. {
  24. if(a<=i && i<=b)
  25. {
  26. ll m=i-a;
  27. div[m]++;
  28. //cout<<"L";
  29. //cout<<"Hi";
  30. }
  31. }
  32. }
  33. if(a==1)
  34. {
  35. div[0]=1;
  36. }
  37. for(int i=0; i<=(b-a); i++)
  38. {
  39. if(div[i]==n)
  40. {
  41. //cout<<i<<" ";
  42. count++;
  43. }
  44. }
  45. cout<<count;
  46. end=clock();
  47. //cout<<(float)(end-start)/CLOCKS_PER_SEC;
  48. }
Success #stdin #stdout 0s 4408KB
stdin
Standard input is empty
stdout
Standard output is empty