diff --git a/POJ/1179_gj-Acit.cpp b/POJ/1179_gj-Acit.cpp new file mode 100644 index 0000000..651db10 --- /dev/null +++ b/POJ/1179_gj-Acit.cpp @@ -0,0 +1,102 @@ +#include +#include +#include +#include +#include +#include +#include +#define MAX(a,b) (a) > (b)? (a):(b) +#define MIN(a,b) (a) < (b)? (a):(b) +#define mem(a) memset(a,0,sizeof(a)) +#define INF 1000000007 +#define MAXN 20005 +using namespace std; + +bool op[105]; +int num[105],dp_max[10005], dp_min[10005], n; +bool vis_max[10005],vis_min[10005]; +int DP_MIN(int i,int j); +int DP_MAX(int i,int j); + + +int DP_MAX(int i,int j)//DP求区间最大值 +{ + int u = i*100+j; + if(vis_max[u])return dp_max[u]; + vis_max[u]=1; + if(j-i <= 1) + { + if(j==i)return dp_max[u]=num[i-1]; + if(!op[i])return dp_max[u]=num[i-1]+num[i]; + else return dp_max[u]=num[i-1]*num[i]; + } + dp_max[u] = -INF; + for(int k=i;k