码迷,mamicode.com
首页 > 其他好文 > 详细

hdu 2571 命运

时间:2017-10-04 14:29:06      阅读:192      评论:0      收藏:0      [点我收藏+]

标签:sig   syn   gre   name   include   cos   cout   ack   pre   

#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 命运

标签:sig   syn   gre   name   include   cos   cout   ack   pre   

原文地址:http://www.cnblogs.com/Aragaki/p/7625349.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!