四片绿叶衬六株红花,孩子懵逼了,求助/kk
查看原帖
四片绿叶衬六株红花,孩子懵逼了,求助/kk
298549
SIXIANG32楼主2021/1/30 19:39
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
__int128 pow[110],f[110][110];
int a[110][110];
int max(__int128 x,__int128 y){return ((x>y)?(x):(y));}
void write(__int128 x)
{
    if(!x)return ;
    if(x>9)write(x/10);
    cout<<int(x%10);
}
signed main()
{
	int n,m;
    __int128 ans=0;
	cin>>n>>m;
	for(int p=1;p<=n;p++)
		for(int i=1;i<=m;i++)
			cin>>a[p][i];
	for(int p=1;p<=n;p++)
	{
		for(int i=1;i<=m;i++)
			for(int j=1;j<=m;j++)
				f[i][j]=0;
		for(int len=0;len<=m;len++)
            for(int i=1;i+len<=m;i++)
                f[i][i+len]=max(2*f[i+1][i+len]+2*a[p][i],2*f[i][i+len-1]+2*a[p][i+len]);
		ans+=f[1][m];
	}
    if(ans==0)cout<<0<<endl;
	else write(ans);
}

dp 吃人!救救孩子!/kk

2021/1/30 19:39
加载中...