Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
Register

## 提供两种代码，仅供参考哈~~~

Posted by yousiki at 2016-07-28 17:42:48 on Problem 1664
```int t, n, m, dp[15][15];
inline int DP(int x, int y) {
if (~dp[x][y])return dp[x][y];
if (x == 1 || y == 0)return dp[x][y] = 1;
if (x > y)return dp[x][y] = DP(y, y);
return dp[x][y] = DP(x - 1, y) + DP(x, y - x);
}
signed main(void) {
memset(dp, -1, sizeof(dp));
for (scanf("%d", &t); t; t--) {
scanf("%d%d", &m, &n);
printf("%d\n", DP(n, m));
}
}

int t, n, m, dp[15][15][15], ans[15][15];
signed main(void) {
memset(dp, 0, sizeof(dp)), dp[0][0][0] = 1;
for (int i = 0; i <= 10; i++)
for (int j = 0; j <= 10; j++)
for (int k = 0; k <= j; k++)
for (int l = k; j + l <= 10; l++)
dp[i + 1][j + l][l] += dp[i][j][k];
for (n = 1; n <= 10; n++)for (m = 1; m <= 10; m++) {
ans[n][m] = 0; if (m == 0) { ans[n][m] = 1; continue; }
for (int i = 0; i <= 10; i++)ans[n][m] += dp[n][m][i];
}
for (scanf("%d", &t); t; t--)scanf("%d%d", &n, &m), printf("%d\n", ans[m][n]);
}

Followed by: