Submission #201480

#TimeUsernameProblemLanguageResultExecution timeMemory
201480Osama_AlkhodairyZapina (COCI20_zapina)C++17
110 / 110
648 ms1916 KiB
#include <bits/stdc++.h> using namespace std; #define finish(x) return cout << x << endl, 0 #define ll long long const int N = 351; int n, dp[N][N][2], C[N][N], mod = 1e9 + 7; int solve(int idx, int s, bool b){ if(idx == n + 1) return s == 0 && b; int &ret = dp[idx][s][b]; if(ret != -1) return ret; ret = 0; for(int i = 0 ; i <= s ; i++){ ret = (ret + 1LL * C[s][i] * solve(idx + 1, s - i, b | (i == idx))) % mod; } return ret; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); memset(dp, -1, sizeof dp); C[0][0] = 1; for(int i = 1 ; i < N ; i++){ C[i][0] = 1; for(int j = 1 ; j < N ; j++){ C[i][j] = C[i - 1][j] + C[i - 1][j - 1]; if(C[i][j] >= mod) C[i][j] -= mod; } } cin >> n; cout << solve(1, n, 0) << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...