Facebook
From Lam, 1 Month ago, written in C++.
Embed
Download Paste or View Raw
Hits: 137
  1. #include<bits/stdc++.h>
  2.  long long n,e=0,kq=0,bien=0;
  3.  bool ktra[100000];
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.  ios_base::sync_with_stdio(false);
  9.  cin.tie(NULL);
  10.  cout.tie(NULL);
  11.  
  12. freopen("BEAUNUM.inp","r",stdin);
  13. freopen("BEAUNUM.out","w",stdout);
  14.    memset(ktra,true,sizeof(ktra));
  15.  ktra[0]=ktra[1]=false;
  16.  for(int i=2;i*i<=1e5+5;i++)
  17.  {
  18.   if (ktra[i])
  19.    for (int j=i*i;j<=1e5+5;j+=i)
  20.    {
  21.     ktra[j]=false;
  22. }
  23.   }
  24.   cin>>n;
  25.   while (bien<n)
  26.  {
  27.    e++;
  28.   if (ktra[e])
  29.    {
  30.    bien=e*e*e*e;
  31.    kq++;
  32.   }
  33.   }
  34.   if (bien>n){
  35.   kq--;
  36.  }
  37.  cout<<kq;
  38.  return 0;
  39. }