标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 16456 Accepted Submission(s): 5750
1 //2016.8.5 2 //HDU2571 3 #include<iostream> 4 #include<cstdio> 5 #include<cstring> 6 7 using namespace std; 8 9 const int inf = 9999999; 10 int mapp[25][1005]; 11 int dp[25][1005]; 12 int n, m; 13 14 int main() 15 { 16 int T; 17 cin>>T; 18 while(T--) 19 { 20 cin>>n>>m; 21 for(int i = 1; i <= n; i++) 22 for(int j = 1; j <= m; j++) 23 scanf("%d", &mapp[i][j]); 24 memset(dp, -inf, sizeof(dp)); 25 dp[0][1] = dp[1][0] = 0; 26 for(int i = 1; i <= n; i++) 27 for(int j = 1; j <= m; j++) 28 { 29 dp[i][j] = max(dp[i-1][j], dp[i][j-1]); 30 for(int k = 2; k <= j; k++) 31 { 32 if(j%k==0)dp[i][j] = max(dp[i][j], dp[i][j/k]); 33 } 34 dp[i][j]+=mapp[i][j]; 35 } 36 cout<<dp[n][m]<<endl; 37 } 38 return 0; 39 }
标签:
原文地址:http://www.cnblogs.com/Penn000/p/5742825.html