Advertisement
trungore10

test_Group

Aug 30th, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.83 KB | None | 0 0
  1. /// opinion : answer is n/2
  2. #include<bits/stdc++.h>
  3. #define int             long long
  4. using namespace std;
  5.  
  6. const int N = 2e5 + 4;
  7. int n, Sum[N];
  8. bool dp[N], Prime[N];
  9.  
  10. void prepare() {
  11.     memset(Prime, true, sizeof(Prime)); Prime[1] = Prime[0] = false;
  12.     for (int i = 2; i < N; ++i) {
  13.         if (!Prime[i]) continue;
  14.         int j = i*i;
  15.         while (j < N) {
  16.             Prime[j] = false;
  17.             j += i;
  18.         }
  19.     }
  20. }
  21.  
  22. #undef int
  23. int main() {
  24. #define int             long long
  25.     freopen("input.txt", "r", stdin);
  26.  
  27.     n = 1e5;
  28.  
  29.     prepare();
  30.  
  31.     dp[0] = true;
  32.     for (int i = 2; i <= n; i += 2) {
  33.         for (int j = i-1; j >= 1; --j) {
  34.             if ( (i - j + 1) % 2 == 1 ) continue;
  35.             if (Prime[j+i] && dp[j-1]) { dp[i] = true; break; }
  36.         }
  37.     }
  38.  
  39.     for (int i = 2; i <= n; i += 2) {
  40.         if (!dp[i]) { cerr << i << " --> WA \n"; exit(0); }
  41.     }
  42.     cout << "AC" << '\n';
  43.  
  44.     return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement