Facebook
From Trần Vũ Hải Đăng, 1 Month ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 132
  1. #include<set>
  2. #include<map>
  3. #include<queue>
  4. #include<ctime>
  5. #include<array>
  6. #include<cmath>
  7. #include<string>
  8. #include<bitset>
  9. #include<vector>
  10. #include<random>
  11. #include<chrono>
  12. #include<cstring>
  13. #include<cassert>
  14. #include<complex>
  15. #include<cstdio>
  16. #include<cstdlib>
  17. #include<iostream>
  18. #include<algorithm>
  19. #include <unordered_set>
  20. #include <unordered_map>
  21.  
  22. // define some stuffs
  23. #define inf 0x3f
  24. #define EPS 1.0e-4
  25. #define maxD 10000
  26. #define BUF_SZ 1 << 15
  27. #define COSO 100000000
  28. #define PI 3.1415926535897932384626433832795
  29.  
  30. #define fi first
  31. #define se second
  32. #define pii pair<int, int>
  33. #define piii pair<pii, int>
  34. #define sz(x) (int)(x).size()
  35. #define all(x)  (x).begin(), (x).end()
  36.  
  37. #define ll long long
  38. #define ll long long
  39. #define ld long double
  40. #define ull unsigned long long
  41.  
  42. #define pub push_back
  43. #define pob pop_back
  44. #define puf push_front
  45. #define pof pop_front
  46.  
  47. #define MASK(i) (1LL<<(i))
  48. #define BIT(x,i) (((x)>>(i))&1)
  49. #define ALL(v) (v).begin(),(v).end()
  50. #define __builtin_popcount __builtin_popcountll
  51.  
  52. using namespace std;
  53.  
  54. // Set up some constants
  55. const int sll = 20;
  56. const int sz1 = 1e5 + 15;
  57. const int sz2 = 1e6 + 15;
  58. const int sz3 = 1e7 + 15;
  59. const int MOD1 = 1e7 + 5;
  60. const int MOD2 = 1e9 + 5;
  61. const int d4i[4] = {-1, 0, 1, 0};
  62. const int d4j[4] = {0, 1, 0, -1};
  63. const int d8i[8]={-1, -1, 0, 1, 1, 1, 0, -1};
  64. const int d8j[8]={0, 1, 1, 1, 0, -1, -1, -1};
  65.  
  66. // some necessary functions
  67. inline namespace Input {
  68. int pos, len;
  69. char buf[BUF_SZ];
  70.  
  71. char next_char() {
  72.  if (pos == len) {
  73.   pos = 0;
  74.   len = (int)fread(buf, 1, BUF_SZ, stdin);
  75.   if (!len) {
  76.    return EOF;
  77.   }
  78.  }
  79.  return buf[pos++];
  80. }
  81.  
  82. int read_int() {
  83.  int x;
  84.  char ch;
  85.  int sgn = 1;
  86.  while (!isdigit(ch = next_char())) {
  87.   if (ch == '-') {
  88.    sgn *= -1;
  89.   }
  90.  }
  91.  x = ch - '0';
  92.  while (isdigit(ch = next_char())) {
  93.   x = x * 10 + (ch - '0');
  94.  }
  95.  return x * sgn;
  96. }
  97. }
  98.  
  99. inline namespace Output {
  100. char buf[BUF_SZ];
  101. int pos;
  102.  
  103. void flush_out() {
  104.  fwrite(buf, 1, pos, stdout);
  105.  pos = 0;
  106. }
  107.  
  108. void write_char(char c) {
  109.  if (pos == BUF_SZ) {
  110.   flush_out();
  111.  }
  112.  buf[pos++] = c;
  113. }
  114.  
  115. void write_int(int x) {
  116.  static char num_buf[100];
  117.  if (x < 0) {
  118.   write_char('-');
  119.   x *= -1;
  120.  }
  121.  int len = 0;
  122.  for (; x >= 10; x /= 10) {
  123.   num_buf[len++] = (char)('0' + (x % 10));
  124.  }
  125.  write_char((char)('0' + x));
  126.  while (len) {
  127.   write_char(num_buf[--len]);
  128.  }
  129.  write_char('\n');
  130. }
  131.  
  132. void init_output() { assert(atexit(flush_out) == 0); }
  133. }
  134.  
  135. int read() {
  136.  int s = 0, f = 1; char ch = getchar();
  137.  for(; ch < '0' || ch > '9'; ch = getchar()) if (ch == '-')  f = 1;
  138.  for(; '0' <= ch && ch <= '9'; ch = getchar()) s = s * 10 + ch - '0';
  139.  return s * f;
  140. }
  141.  
  142. void write(int x) {
  143.     if (x >= 10)
  144.         write(x / 10);
  145.     putchar (x % 10 + '0');
  146. }
  147.  
  148. void BoostCompile(void) {
  149.  ios_base::sync_with_stdio(false);
  150.  cin.tie(NULL); cout.tie(NULL);
  151. }
  152.  
  153. void SetUpFile&#40;void&#41; {
  154.  freopen("NAME.inp", "r", stdin);
  155.  freopen("NAME.out", "w", stdout);
  156. }
  157.  
  158. /* Author : Trần Vũ Hải Đăng */
  159. const int N = 1e6 + 15;
  160.  
  161. long long n, kq = 0;
  162. bool check[N];
  163.  
  164. void sieve() {
  165.     memset(check, true, sizeof(check));
  166.     check[0] = false;
  167.     check[1] = false;
  168.     for(int i = 2; i * i <= N; ++i) {
  169.         if (check[i] == true) {
  170.             for(int j = i * i; j <= N; j += i) {
  171.                 check[j] = false;
  172.             }
  173.         }
  174.     }
  175. }
  176.  
  177. void Solution(void) {
  178.     sieve();
  179.     cin >> n;
  180.     n = sqrt(sqrt(n));
  181.     for(int i = 1; i <= n; ++i) kq += check[i];
  182.     cout << kq;
  183. }
  184.  
  185. signed main (void) {
  186.  BoostCompile();
  187.  freopen("beaunum.inp", "r", stdin);
  188.  freopen("beaunum.out", "w", stdout);
  189.  Solution();
  190.  return 0;
  191. }
  192.  
  193. /* That's all about my code*/
  194.  
  195.