标签: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; } }
标签:sig syn gre name include cos cout ack pre
原文地址:http://www.cnblogs.com/Aragaki/p/7625349.html