标签:des style blog http io color ar os java
DP详解见:
http://blog.csdn.net/liguan1/article/details/10468139
+- ++---
1 13
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long int LL;
LL dp[50][50];
char str[50];
int main()
{
while(cin>>str)
{
if(str[0]=='-')
{
puts("0"); continue;
}
memset(dp,0,sizeof(dp));
int n=strlen(str);
dp[1][1]=1;
for(int i=2;i<=n;i++)
{
for(int j=0;j<=i;j++)
{
if(str[i-1]=='+')
{
if(j) dp[i][j]+=dp[i-1][j-1];
dp[i][j]+=dp[i-1][j]*j;
}
else if(str[i-1]=='-')
{
dp[i][j]+=dp[i-1][j]*j;
dp[i][j]+=dp[i-1][j+1]*(j+1)*(j+1);
}
}
}
cout<<dp[n][0]<<endl;
}
return 0;
}
标签:des style blog http io color ar os java
原文地址:http://blog.csdn.net/ck_boss/article/details/40837027