Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
大家可以进一步做整数划分的题 HOJ1402 综合性比较好,有兴趣可以看看这是我的AC代码 #include <iostream> #include <cstdlib> using namespace std; int main(int argc, char** argv) { int f[22][22]; memset(f, 0, sizeof (f)); f[0][0] = 1; for (int i = 1; i < 21; ++i)for (int j = 1; j <= i; ++j) { f[i][j] = f[i - 1][j - 1] + f[i - j][j]; } int cas; cin >> cas; while (cas--) { int sum = 0; int m, n; cin >> m >> n; for (int i = 1; i <= n; i++) { sum += f[m][i]; } printf("%d\n", sum); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator