Advertisement
YEZAELP

CUBE-031: ต้นมะนาวทวิภาค (Binary lemon tree)

Oct 23rd, 2020 (edited)
119
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.40 KB | None
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. using lli = long long;
  5. const lli N = 909091;
  6.  
  7. int main(){
  8.  
  9.     int n;
  10.     scanf("%d", &n);
  11.  
  12.     lli dp[n+1];
  13.     dp[0] = 1;
  14.     dp[1] = 1;
  15.     for(int i=2;i<=n;i++){
  16.         dp[i] = 0;
  17.         for(int j=1;j<=i;j++){
  18.             dp[i] += dp[j-1] * dp[i-j];
  19.             dp[i] %= N;
  20.         }
  21.     }
  22.     printf("%lld", dp[n]);
  23.  
  24.     return 0;
  25. }
  26.  
Advertisement
RAW Paste Data Copied
Advertisement