Advertisement
Guest User

Untitled

a guest
Nov 29th, 2015
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. #include <cmath>
  2. #include <iostream>
  3. #include <map>
  4. #include <fstream>
  5. #include <vector>
  6.  
  7. using namespace std;
  8. const int N = 10000000;
  9.  
  10. int main()
  11. {
  12.  
  13. int lp[N+1];
  14. vector< long long > pr;
  15.  
  16. for (int i=2; i<=N; ++i)
  17. {
  18. if (lp[i] == 0)
  19. {
  20. lp[i] = i;
  21. pr.push_back (i);
  22. }
  23. for (int j=0; j<(int)pr.size() && pr[j]<=lp[i] && i*pr[j]<=N; ++j)
  24. lp[i * pr[j]] = pr[j];
  25. }
  26.  
  27. long long n;
  28. long long ans=0;
  29. int p;
  30. cin >> n >> p;
  31. for (int i = 0; i < pr.size(); i++){
  32. bool f=true;
  33. long long cur=1;
  34. for (int j = 0; j < p-1; j++){
  35. if (cur*pr[i]<=n){
  36. cur*=pr[i];
  37. }
  38. else{
  39. f=false;
  40. break;
  41. }
  42. }
  43. if (f){
  44. ans++;
  45. }
  46. else{
  47. break;
  48. }
  49. }
  50. cout <<ans<<endl;
  51.  
  52.  
  53. return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement