Last active
August 18, 2021 20:46
-
-
Save LucaDantas/a04c263bfacb238433765eda175eb222 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
const int maxn = 510; | |
int dp[maxn][maxn], n; | |
bool mark[maxn][maxn]; | |
int solve(int pos, int last) { | |
if(pos == n) return 1; | |
if(mark[pos][last]) return dp[pos][last]; | |
for(int i = pos+last+1; i <= n; i++) // já lidamos com as restrições dentro do for para simplificar a implementação | |
dp[pos][last] += solve(i, i-pos); | |
mark[pos][last] = 1; | |
return dp[pos][last]; | |
} | |
int main() { | |
scanf("%d", &n); | |
printf("%d\n", solve(1, 0)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment