SHARE
TWEET

Untitled

a guest Jan 20th, 2020 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #ifdef FAST_ALLOCATOR_MEMORY
  2. int allocator_pos = 0;
  3.   char allocator_memory[(int)FAST_ALLOCATOR_MEMORY];
  4.   inline void * operator new ( size_t n ) {
  5.     char *res = allocator_memory + allocator_pos;
  6.     allocator_pos += n;
  7.     assert(allocator_pos <= (int)FAST_ALLOCATOR_MEMORY);
  8.     return (void *)res;
  9.   }
  10.   inline void operator delete ( void * ) noexcept { }
  11.   //inline void * operator new [] ( size_t ) { assert(0); }
  12.   //inline void operator delete [] ( void * ) { assert(0); }
  13. #endif
  14.  
  15. #pragma GCC optimize("Ofast")
  16. #pragma GCC optimize("no-stack-protector")
  17. #pragma GCC optimize("unroll-loops")
  18. #pragma GCC optimize("unswitch-loops")
  19. #pragma GCC optimize("fast-math")
  20. #pragma GCC optimize("O3")
  21. #pragma GCC target("avx")
  22. #pragma GCC target("avx2")
  23. #pragma GCC target("popcnt")
  24.  
  25. #include <bits/stdc++.h>
  26.  
  27. #define ll long long
  28. #define ff first
  29. #define ss second
  30. #define pb push_back
  31. #define pf push_front
  32. #define all(x) x.begin(), x.end()
  33. #define sz(x) (int)x.size()
  34.  
  35. using namespace std;
  36.  
  37. const ll mod = 998244353;
  38. const int maxn = 1e6 + 100;
  39.  
  40. inline int add(ll a, const ll& b)
  41. {
  42.     a += b;
  43.     if (a >= mod) a -= mod;
  44.     return a;
  45. }
  46.  
  47. inline int sub(ll a, const ll& b)
  48. {
  49.     a -= b;
  50.     if (a < 0) a += mod;
  51.     return a;
  52. }
  53.  
  54. inline int mul(const ll& a, const ll& b) { return (a * b) % mod; }
  55.  
  56. int dp[maxn];
  57.  
  58. signed main()
  59. {
  60.     ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  61.     dp[1] = 1;
  62.     for (int i = 3; i <= (int)1e6; i += 2)
  63.     {
  64.         dp[i] = mul(3, dp[i - 2]);
  65.         int res = 0;
  66.         for (int j = 1; j <= i - 4; j += 2) res = add(res, mul(dp[j], dp[i - j - 3]));
  67.         dp[i] = add(dp[i], mul(2, res));
  68.     }
  69.     for (int i = 0; i <= (int)1e6; ++i) cout << dp[i] << " ";
  70.     return 0;
  71. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top