A - Robot Bicorn Attack

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
 1 #include <stdio.h>
 2 #include <string.h>
 3 #define LL __int64
 4
 5 int main()
 6 {
 7     int i,j,k,n,a,b,c,max,l,flag=0;
 8     char s[32];
 9     gets(s);
10     max=a=0;
11     n=strlen(s);
12     for(i=0;i<n-2;i++)
13     {
14         a=a*10+s[i]-‘0‘;
15         if(a>1000000)break;
16         b=0;
17         for(j=i+1;j<n-1;j++)
18         {
19             b=b*10+s[j]-‘0‘;
20             if(b>1000000)break;
21             l=c=0;
22             for(k=j+1;k<n;k++)
23             {
24                 c=c*10+s[k]-‘0‘;
25                 if(c>1000000)break;
26                 if(c==0&&s[k]==‘0‘&&k!=n-1)
27                     break;
28             }
29             if(k==n&&c<=1000000)l=flag=1;
30             if(l)
31             {
32                 if(max<a+b+c)max=a+b+c;
33     //            printf("%d %d %d\n",a,b,c);
34             }
35             if(b==0&&s[j]==‘0‘)break;
36         }
37         if(a==0&&s[i]==‘0‘)break;
38     }
39     if(flag)printf("%d\n",max);
40     else puts("-1");
41     return 0;
42 }
时间: 2024-10-22 14:24:16

A - Robot Bicorn Attack的相关文章

Artificially intelligent robot scientist &#39;Eve&#39; could boost search for new drugs

图:机器人科学家 “夏娃” Date: February 3, 2015 Source: University of Cambridge Summary: Eve, an artificially intelligent 'robot scientist' could make drug discovery faster and much cheaper, say researchers writing in the Royal Society journal Interface. The te

CodeForces 321 A - Ciel and Robot

[题目链接]:click here~~ [题目大意]:一个robot 机器人 ,可以根据给定的指令行动,给你四种指令,robot初始位置是(0,0),指令一出,robot会重复行动,判断能否在无限行动的情况下经过点(n,m). [解题思路]其实仔细模拟一下,可以发现是有周期的,判断即可,见代码吧~~ 代码: #include <iostream> #include <algorithm> #include <bits/stdc++.h> using namespace

Robot Framework自动化测试(五)--- 开发系统关键字

最近一直在用robot framework 做自动化测试项目,老实说对于习惯直接使用python的情况下,被框在这个工具里各种不爽,当然,使用工具的好处也很多,降低了使用成本与难度:当然,在享受工具带来便利的同时也会受制于工具.对于特定的需求,工具没提供相关的Library和关键字的时候,就只能放弃了. 还好robot framework提供了 Evaluate 关键字,对于Evaluate 关键字的使用等有时间再讲.当robot framework 不能解决需求,我是直接写个.py 程序,通过

ZOJ 2587 Unique Attack 判断最小割是否唯一

很裸的判断最小割是否唯一.判断方法是先做一遍最大流求最小割,然后从源点和汇点分别遍历所有能够到达的点,看是否覆盖了所有的点,如果覆盖了所有的点,那就是唯一的,否则就是不唯一的. #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> #include <climits> #include <string> #include <iostr

Robot Framework + Selenium2环境安装

操作系统环境:Windows XP 安装包: 1. 安装Python Python是一切的基础 版本:python-2.7.6.msi 下载地址:https://www.python.org/downloads/ 2. 安装wxPython wxPython是Python语言的一套GUI图形库:ride需要wxPython的支持 版本:wxPython2.8-win32-unicode-2.8.12.1-py27.exe 下载地址:http://sourceforge.net/projects/

【树状数组区间修改单点查询】HDU 4031 Attack

http://acm.hdu.edu.cn/showproblem.php?pid=4031 [题意] 有一个长为n的长城,进行q次操作,d为防护罩的冷却时间,Attack表示区间a-b的墙将在1秒后受到攻击, 询问表示计算第a块墙受到攻击的次数,被防护罩抵消的不算 [思路] 总的攻击次数-防护罩抵消的次数 总的攻击次数可以树状数组维护 防护罩抵消的模拟 [AC] 1 #include<bits/stdc++.h> 2 using namespace std; 3 typedef long l

Robot Framework常用关键字介绍

下面关键字全部由 Builtin 库提供,Builtin 为 Robot Framework 标准类库.Builtin库提供常用的关键字 1.log log 关键字就是编程语言里的"print"一样,可以打印任何你想打印的内容. 2.定义变量 通过"Set variable"关键字来定义变量 3.连接对象 "Catenate"关键字可以连接多个信息 加上"SEPARATOR="可以对多个连接的信息进行分割. 4.定义列表 通过

dwr的A request has been denied as a potential CSRF attack.错误

虽然DWR是个很早就出现的Ajax框架,但一直都没去使用过,今天正好没事就看了一下并参照文档照做了个demo, 在其中碰到一个问题: 后台打印出错误信息:"严重: A request has been denied as a potential CSRF attack." 在网上google一把 之后,出现此错误的原因大都是说"请求被拒绝,可能存在csrf(cross-site request forgeries,跨站请求伪造)攻击. 页面URL可能被跨站了的服务所调用之类的

在linux下搭建Robot Framework

在linux下搭建自动化测试框架Robot Framework,可以实现多用户同时登录并进行自动化脚本编写,相互之间没有影响. linux系统:fedora 21 步奏 描述 动作 note 1 Install Python yum install python yum list python  /* can view which python version will be installed */ 2 Install easy_install sudo yum install python-