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. redis的lists类型

    List是一个链表结构 , 主要功能是push . pop .获取一个范围的所有值等等 , 操作中key理解为链表的名字 . redis 的 list类型其实就是一个每个子元素都是string类型的双 ...

  2. mysqldump造成Buffer Pool污染的研究

    前言: 最近Oracle MySQL在其官方Blog上贴出了 5.6中一些变量默认值的修改.其中innodb_old_blocks_time 的默认值从0替换成了1000(即1s) 关于该参数的作用摘 ...

  3. CSS选择器的特殊性

    在我们为元素添加样式的时候,或多或少会出现一个元素会有几个不同规则的样式.有#id的,有.class,直接标签元素的,还有各种组合起来的选择器.那CSS到底如何解决这些冲突呢,我们这次专门来探讨一下. ...

  4. source insight 支持CC 文件

    今天开始阅读LevelDB的代码,用source insight建立工程,但其不支持cc后缀的C++文件. 找到这篇<source insight看cc文件> 解决的根本办法:Option ...

  5. mysql删除重复记录语句,删除除了 id 号不同,其他都相同的学生冗余信息

    /** 在Mysql下执行: delete from my.stu where id not in( select min(id) id from my.stu group by code) ; 用途 ...

  6. flex 弹性合模型

    网页布局(layout)是CSS的一个重点应用. 布局的传统解决方案,基于盒状模型,依赖 display属性 + position属性 + float属性.它对于那些特殊布局非常不方便,比如,垂直居中 ...

  7. Jquery EasyUi实战教程布局篇

    转自:http://www.kwstu.com/ArticleView/kwstu_20139413501290 送给大家一个非常好的后台布局模板,本人后来就选择了这个模板http://www.kws ...

  8. socket的shutdown与close

    shutdown原型 int shutdown(int socket, int how); socket 指定socket的文件描述符 how    指定shutdown的类型 SHUT_RD 禁止读 ...

  9. Mac使用指南

    1.csrutil命令 简单来说 是苹果在新系统后加入的一个安全机制. Rootless讨论的前提是假定root账户是OS X(或者其他Unix系统)中对抗恶意程序保护操作系统的最后一道防线.意思是一 ...

  10. [JS 基础] touchEvent中的changedTouches,targetTouches和touches的区别

    对于移动端开发中 touchEvent(触摸事件) 中changedTouches,targetTouches和touches的区别往往不容易弄清,故特意查询了 MDN相关资料 1. 其中,对 cha ...