标签:style blog color io os for div sp 代码
最近一直在做noip的题,由于太水一直没有写题解,可是这道题,这道题。啊啊啊啊……
明明水的要命,调了一节课啊!!我干脆不要搞OI了啊!
特别逗比的错误啊!!!!
代码:
#include <cstdio> #include <cstring> #include <iostream> #include <cstdlib> #include <algorithm> #define N 251 using namespace std; int n; int a[N][N]; int val[N]; int main() { scanf("%d", &n); memset(a, 0, sizeof(a)); for (int i = 1; i <= n; ++i) { int x; scanf("%d", &x); val[i] = val[i+n] = x; } for (int j = 1; j < n; ++j) for (int i = 1; i <= 2*n, i+j <= 2*n; ++i) // i 一定要到 2*n !!!!! for (int k = i; k < i+j; ++k) a[i][i+j] = max(a[i][i+j], a[i][k] + a[k+1][i+j] + val[i]*val[k+1]*val[i+j+1]); int ans = 0; for (int i = 1; i <= n; ++i) ans = max(ans, a[i][i+n-1]); printf("%d\n", ans); return 0; }
标签:style blog color io os for div sp 代码
原文地址:http://www.cnblogs.com/handsomeJian/p/3973570.html