DP最最经典的入门题~~~好吧~~我只是在往后面刷而已~~这章开头是介绍的二进制的说~~不知咋地第一道题居然是个毫无关系的DP....
Program:
/* ID: zzyzzy12 LANG: C++ TASK: numtri */ #include #include #include #include #include #include using namespace std; int dp[2][1005],n,i,k,p,x,ans; int main() { freopen("numtri.in","r",stdin); freopen("numtri.out","w",stdout); scanf("%d",&n); memset(dp,0,sizeof(dp)); k=0; scanf("%d",&dp[0][1]); for (p=2;p<=n;p++) { k=1-k; scanf("%d",&x); dp[k][1]=dp[1-k][1]+x; for (i=2;idp[k][i]?ans:dp[k][i]; printf("%d\n",ans); return 0; }