其他分享
首页 > 其他分享> > Daimayuan Online Judge #558. 快快变大

Daimayuan Online Judge #558. 快快变大

作者:互联网

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define debug cout<<"!!!"<<endl;
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define ROF(i, a, b) for (int i = (a); i >= (b); i--)
const int N = 305, mod=1000003;
int n, a[N][N], f[N][N];

inline void mul(int&a,int b){a=a*b%mod;}
inline void getmx(int&a,int b){a=max(a,b);}
inline int pingfang(int x){return x*x;}
signed main(){
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin>>n; FOR(i,1,n) cin>>a[i][i];
    FOR(i,1,n) FOR(j,i+1,n) a[i][j]=a[j][j], mul(a[i][j],a[i][j-1]);

    FOR(i,2,n) for(int l=1,r=l+i-1; r<=n; l++,r++){
        for(int k=l; k<r; k++) getmx(f[l][r],f[l][k]+f[k+1][r]+pingfang(a[l][k]-a[k+1][r]));
    }
    cout<<f[1][n];
} 

标签:558,int,Daimayuan,cin,long,mul,Judge,inline,cout
来源: https://blog.csdn.net/bunny_1024/article/details/123578162