#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;
int a[21][1005];
int max(int n,int m)
{
return n>m? n:m;
}
int main()
{
int i,j,k,temp;
int t;
int n,m;
cin>>t;
while(t--)
{
cin>>n>>m;
for(i=1;i<=n;i++)
{
for(j=1;j<=m;j++)
{
cin>>a[i][j];
}
}
for(i=1;i<=n;i++)
{
for(j=1;j<=m;j++)
{
if(i==1&&j==1)
{
continue;
}
if(i==1)
{
temp=a[i][j-1];
}
else
{
if(j==1)
{
temp=a[i-1][j];
}
else
{
temp=max(a[i-1][j],a[i][j-1]);
}
}
for(k=1;k<j;k++)
{
if(j%k==0)
{
temp=max(temp,a[i][k]);
}
}
a[i][j]+=temp;
}
}
cout<<a[n][m]<<endl;
}
return 0;
}
找不到做题感觉,决定从以前的专题开始复习,先写几道题练练手。