hdu 2571 命运

Posted Aragaki

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了hdu 2571 命运相关的知识,希望对你有一定的参考价值。

#include <bits/stdc++.h>
#define PI acos(-1.0)
#define mem(a,b) memset((a),b,sizeof(a))
#define TS printf("!!!\n")
#define pb push_back
//std::ios::sync_with_stdio(false);
using namespace std;
//priority_queue<int,vector<int>,greater<int>> que;
const double EPS = 1.0e-8;
typedef pair<int, int> pairint;
typedef long long ll;
typedef unsigned long long ull;
const int  maxn = 2e5 + 100;
const int  maxm = 300;
//next_permutation
//priority_queue<int, vector<int>, greater<int>> que;
int dp[25][2005];
int f[25][1005];
ll num[1005];
int main()
{
        //freopen("bonuses.in", "r", stdin);
        //freopen("out.txt", "w", stdout);
        int t ;
        cin >> t;
        while (t--)
        {
                int n, m;
                cin >> n >> m;
                for (int i = 1; i <= n; i++)
                        for (int j = 1; j <= m; j++)
                        {
                                scanf("%d", &f[i][j]);
                        }
                for (int i = 0; i <= n; i++)
                {
                        dp[0][i] = dp[i][0] = -99999;
                }
                dp[1][0] = dp[0][1] = 0;
                for (int i = 1; i <= n; i++)
                {
                        for (int j = 1; j <= m; j++)
                        {
                                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
                                for (int k = 1; k <= j / 2; k++)
                                {
                                if(j%k==0)
                                {
                                dp[i][j]=max(dp[i][j],dp[i][k]);
                                }
                                }
                                dp[i][j]+=f[i][j];
                        }
                }
                cout<<dp[n][m]<<endl;
        }
}

 

以上是关于hdu 2571 命运的主要内容,如果未能解决你的问题,请参考以下文章

HDU 2571 命运(简单DP)

命运(HDU 2571 简单动态规划)

hdu2571 命运(动态规划)

hdu 2571 命运

hdu2571命运bfs

HDU 2571 命运