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 |
AC很简单的动态规划#include <iostream> using namespace std; int dp[30 + 1][30 + 1]; int main() { int G, L; for (int i = 0; i <= 30; ++i) dp[1][i] = 1; for (int i = 1; i <= 30; ++i) dp[i][0] = i; for (int i = 2; i <= 30; ++i) { for (int j = 1; j <= 30; ++j) { dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j] + 1; } } int cnt = 0; while (1) { cin >> G >> L; if(G == 0 && L == 0) break; cnt += 1; cout << "Case " << cnt << ": " << dp[G][L] << endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator