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

AC很简单的动态规划

Posted by On18 at 2020-04-14 21:31:46 on Problem 1243
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator