mickypinata

CUBE-T031: Binary Lemon Tree

Jul 24th, 2021
1,223
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef long long lli;
  5.  
  6. const int N = 1e4;
  7. const int PM = 909091;
  8.  
  9. int dp[N + 10];
  10.  
  11. int main(){
  12.  
  13.     int x;
  14.     scanf("%d", &x);
  15.     dp[0] = 1;
  16.     dp[1] = 1;
  17.     for(int n = 2; n <= x; ++n){
  18.         int sum = 0;
  19.         for(int i = 0; i < n; ++i){
  20.             sum = (sum + ((lli)dp[i] * dp[n - i - 1]) % PM) % PM;
  21.         }
  22.         dp[n] = sum;
  23.     }
  24.     cout << dp[x];
  25.  
  26.     return 0;
  27. }
  28.  
RAW Paste Data