Description

Vasya plays Robot Bicorn Attack.

The game consists of three rounds. For each one a non-negative integer amount of points is given. The result of the game is the sum of obtained points. Vasya has already played three rounds and wrote obtained points one by one (without leading zeros) into the string s. Vasya decided to brag about his achievement to the friends. However, he has forgotten how many points he got for each round. The only thing he remembers is the string s.

Help Vasya to find out what is the maximum amount of points he could get. Take into account that Vasya played Robot Bicorn Attack for the first time, so he could not get more than 1000000 (106) points for one round.

Input

The only line of input contains non-empty string s obtained by Vasya. The string consists of digits only. The string length does not exceed 30 characters.

Output

Print the only number — the maximum amount of points Vasya could get. If Vasya is wrong and the string could not be obtained according to the rules then output number -1.

Sample Input

Input
1234
Output
37
Input
9000
Output
90
Input
0009
Output
-1
 #include <stdio.h>
#include <string.h>
#define LL __int64 int main()
{
int i,j,k,n,a,b,c,max,l,flag=;
char s[];
gets(s);
max=a=;
n=strlen(s);
for(i=;i<n-;i++)
{
a=a*+s[i]-'';
if(a>)break;
b=;
for(j=i+;j<n-;j++)
{
b=b*+s[j]-'';
if(b>)break;
l=c=;
for(k=j+;k<n;k++)
{
c=c*+s[k]-'';
if(c>)break;
if(c==&&s[k]==''&&k!=n-)
break;
}
if(k==n&&c<=)l=flag=;
if(l)
{
if(max<a+b+c)max=a+b+c;
// printf("%d %d %d\n",a,b,c);
}
if(b==&&s[j]=='')break;
}
if(a==&&s[i]=='')break;
}
if(flag)printf("%d\n",max);
else puts("-1");
return ;
}

A - Robot Bicorn Attack的更多相关文章

  1. Codeforces Round #115 A. Robot Bicorn Attack 暴力

    A. Robot Bicorn Attack Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/17 ...

  2. 【Checkio Exercise】Robot Sort

    Robot Sort All of the refined ingots should be sorted by size in each lot while passing by on a conv ...

  3. Robot Framework用户手册 (版本:3.0)

    版权信息:诺基亚网络和解决中心 本翻译尊重原协议,仅用于个人学习使用 1.开始: 1.1 介绍: Robot Framework是一个基于Python的,为终端测试和验收驱动开发(ATDD)的可扩展的 ...

  4. selenium webdriver 右键另存为下载文件(结合robot and autoIt)

    首先感谢Lakshay Sharma 大神的指导 最近一直在研究selenium webdriver右键菜单,发现selenium webdriver 无法操作浏览器右键菜单,如图 如果我想右键另存为 ...

  5. RIDE -- Robot Framework setup

    RobotFramework 是一款基于python 的可以实现关键字驱动和数据驱动并能够生成比较漂亮的测试报告的一款测试框架 这里使用的环境是 python-2.7.10.amd64.msi RID ...

  6. [8.2] Robot in a Grid

    Imagine a robot sitting on the upper left corner of grid with r rows and c columns. The robot can on ...

  7. Robot Framework自动化测试 ---视频与教程免费分享

    当我第一次使用Robot Framework时,我是拒绝的.我跟老大说,我拒绝其实对于习惯了代码的自由,所以讨厌这种“填表格”式的脚本.老大说,Robot Framework使用简单,类库丰富,还可以 ...

  8. 【Cocos2d-x for WP8 学习整理】(2)Cocos2d-Html5 游戏 《Fruit Attack》 WP8移植版 开源

    这一阵花了些时间,把 cocos2d-html5 里的sample 游戏<Fruit Attack>给移植到了WP8上来,目前已经实现了基本的功能,但是还有几个已知的bug,比如WP8只支 ...

  9. robot创建桌面图标(转载)

    桌面ride图标,安装之后会自动创建(偶尔也会创建失败),创建桌面图标方法如下: 1. 新建快捷方式 在桌面右击鼠标,弹出的菜单选择 新建-快捷方式 ,然后在"请键入对象"的位置输 ...

随机推荐

  1. 测试的rtsp地址

    无线城市 千里眼 http://218.204.223.237:8081/wap/show_video.php?vd=1  右键->复制链接地址即可获得Rtsp地址.

  2. [Hive - LanguageManual ] Explain (待)

    EXPLAIN Syntax EXPLAIN Syntax Hive provides an EXPLAIN command that shows the execution plan for a q ...

  3. Windows Server 2012 四个版本对比

    Windows Server 2012 有4种版本: Foundation, Essentials, Standard and Datacenter. 版本 Foundation Essentials ...

  4. redis.conf的配置

    daemonize yes   :  redis server 实例是否以后台方式运行 , no:不以后台方式运行(默认) , yes:以后台方式运行. requirepass 密码 :  密码最好长 ...

  5. linux@64 获取时间的性能评估

    听人说gettimeofday 在64bit下有缓存,速度很快,测试下了,感觉不对啊.. #include <time.h> #include <sys/time.h> #in ...

  6. maven系列(3)-maven生命周期的介绍

    1. 概述 Maven有三套相互独立的生命周期,请注意这里说的是"三套",而且"相互独立",初学者容易将Maven的生命周期看成一个整体,其实不然.这三套生命周 ...

  7. delphi读取excel

    简单的例子 procedure TForm1.Button1Click(Sender: TObject); var ExcelApp,MyWorkBook: OLEVariant; begin ope ...

  8. java tools: jmap

    SYNOPSIS jmap [ option ] pid click here to see detail DESCRIPTION jmap prints shared object memory m ...

  9. opennebula 编译日志

    [root@localhost opennebula-]# scons mysql=yes scons: Reading SConscript files ... Testing recipe: xm ...

  10. MongoDB 快速入门--初级

    数据库的操作一般来说都是CRUD,这其中最难的就是查询,所有所我们先来了解MongoDB中的 插入(insert) 说到插入,我们就必须得说说如何创建数据库,如何创建集合,然后才是如何创建文档. 在这 ...