1 /*
2 UVA 11258
3 题意:
4 第一行输入T ;接下来 T 行,每行一个字符串,
5 问怎样分隔这些字符串(分隔出来的数在int范围内) ,加起来的和最大,输出最大和。
6
7 */
8
9 #include<cstdio>
10 #include<algorithm>
11 #include<cstring>
12 #include<iostream>
13 #define ll long long
14 #define INTMAX 2147483647
15 const int maxn=210;
16 using namespace std;
17 ll num[maxn][maxn];
18 ll dp[maxn];
19 char str[maxn];
20 int main()
21 {
22 int t;
23 scanf("%d",&t);
24 getchar();
25 while(t--)
26 {
27 scanf("%s",str+1);
28 int l=strlen(str+1);
29 for(int p=1;p<=11;p++)
30 {
31 for(int i=1,j=p;j<=l;i++,j++)
32 {
33 ll tmp=0;
34 for(int k=i;k<=j;k++)
35 tmp = tmp*10 + (str[k]-48);
36 if(tmp<=INTMAX)
37 num[i][j]=tmp;
38 else num[i][j]=0;
39 }
40 }
41 memset(dp,0,sizeof(dp));
42 for(int i=1;i<=l;i++)
43 for(int j=1;j<=11 && j<=i;j++)
44 dp[i] = max(dp[i],dp[i-j]+num[i-j+1][i]);
45 cout<<dp[l]<<endl;
46 }
47 return 0;
48 }