Facebook
From Lê Hải Đăng, 1 Month ago, written in C++.
Embed
Download Paste or View Raw
Hits: 143
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. long long n,a,b,ans=0;
  5. int x[50001];
  6.  
  7. void sieve(int N) {
  8.     for(int i=0;i<=N;++i)x[i]=1;
  9.     x[0]=0;
  10.     x[1]=0;
  11.     for(int i=2;i*i<=N;++i)
  12.         if(x[i]==1) for(int j=i*i;j<=N;j+=i)x[j]=0;
  13. }
  14. int main()
  15. {
  16.     freopen("BEAUNUM.inp","r",stdin);
  17.     freopen("BEAUNUM.out","w",stdout);
  18.     sieve(35000);
  19.     cin>>n;
  20.     for(int i=1;i<=(int)sqrt(sqrt(n));i++)ans+=x[i];
  21.     cout<<ans;
  22. }

Replies to BEAUNUM rss

Title Name Language When
COUNTNUM Lê Hải Đăng cpp 1 Month ago.