A. Robot Bicorn Attack

Time Limit: 20 Sec

Memory Limit: 256 MB

题目连接

http://codeforces.com/contest/175/problem/A

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

1234

Sample Output

37

HINT

题意

给你一个字符串,要求使得字符串分为3节,并且每节都不能带首位0

并且每一节的数字都不能超过1e6

问你这三节的和最大可能为多少

题解:

暴力咯,数据范围只有30~

不过这道题如果数据范围出到1e5的话,是一道非常好玩的题目哦~

代码:

#include<iostream>
#include<stdio.h>
using namespace std; string s;
long long ans = ;
long long solve(int l,int r)
{
if(l!=r&&s[l]=='')return -;
long long res = ;
for(int i=l;i<=r;i++)
{
res = res * + (s[i]-'');
if(res>)
return -;
}
return res;
}
int main()
{
cin>>s;
int flag = ;
for(int i=;i<s.size();i++)
{
for(int j=i+;j<s.size();j++)
{
long long sum1 = solve(,i-);
long long sum2 = solve(i,j-);
long long sum3 = solve(j,s.size()-);
if(sum1==-||sum2==-||sum3==-)
continue;
ans = max(ans,sum1+sum2+sum3);
flag = ;
}
}
if(flag==)
return puts("-1");
printf("%d\n",ans);
}

Codeforces Round #115 A. Robot Bicorn Attack 暴力的更多相关文章

  1. A - Robot Bicorn Attack

    Description Vasya plays Robot Bicorn Attack. The game consists of three rounds. For each one a non-n ...

  2. Codeforces Round #307 (Div. 2) B. ZgukistringZ 暴力

    B. ZgukistringZ Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/551/probl ...

  3. Codeforces Round #115 B. Plane of Tanks: Pro 水题

    B. Plane of Tanks: Pro Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/17 ...

  4. Codeforces Round #328 (Div. 2) A. PawnChess 暴力

    A. PawnChess Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/592/problem/ ...

  5. Codeforces Round #404 (Div. 2)(A.水,暴力,B,排序,贪心)

    A. Anton and Polyhedrons time limit per test:2 seconds memory limit per test:256 megabytes input:sta ...

  6. Codeforces Round #369 (Div. 2) A B 暴力 模拟

    A. Bus to Udayland time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  7. Codeforces Educational Codeforces Round 5 B. Dinner with Emma 暴力

    B. Dinner with Emma 题目连接: http://www.codeforces.com/contest/616/problem/A Description Jack decides t ...

  8. Codeforces Round #188 (Div. 1) B. Ants 暴力

    B. Ants Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/317/problem/B Des ...

  9. Codeforces Round #329 (Div. 2) A. 2Char 暴力

    A. 2Char Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/593/problem/A De ...

随机推荐

  1. 打通ssh的方法

    为了实现密码免输入,可以在安全的内网环境中打通ssh.linux和cygwin均可,步骤如下: 由A机去B机.在A生成密钥:ssh-keygen -t rsa,一路回车 将A的~/.ssh/id_rs ...

  2. CPC23-4 K.喵喵的神·数

    题意:给出整数T,P,求c(T,P) mod P. 解法:用卢卡斯定理. 卢卡斯定理:解决c(n,m) mod p问题.Lucas(n,m,p)=c(n%p,m%p)*Lucas(n/p,m/p,p) ...

  3. 翻译【ElasticSearch Server】第一章:开始使用ElasticSearch集群(4)

    停止ElasticSearch(Shutting down ElasticSearch) 尽管我们期望集群(或节点)终生完美运行,我们最终可能需要重启或者正确的停止它(例如,维护).有三种方式来停止E ...

  4. KVO KVC

    @interface FoodData : NSObject { NSString * foodName; float foodPrice; } @end ////////////////////// ...

  5. C 实现的算法篇

    算法的定义:算法是解决实际问题的一种精确的描述方法,目前,广泛认同的定义是:算法的模型分析的一组可行的确定的和有穷的规则 算法的五个特性:有穷性,确切性,输入,输出,可行性.目前算法的可执行的步骤非常 ...

  6. 关于ShareSDK接入的各种问题,以及解决方案

    随着社交网络的流行,游戏接入分享已经是必然.毕竟这是非常好的一种推广方式.ShareSDK是一个非常好的内分享提供商!但是接入后发生的各种问题,下面给大家提供几个本人遇到的问题,以及解决方法: 1)微 ...

  7. [GRYZ2015]INCR

    题目描述 数列 A1,A2,...,AN,修改最少的数字,使得数列严格单调递增. 输入格式 第 1 行,1 个整数 N 第 2 行,N 个整数 A1,A2,...,AN 输出格式 1 个整数,表示最少 ...

  8. exists与in的使用与区别

    1.in的使用举例 select * from tableA where id in (select id from tableB) 2.exists的使用举例 select * from table ...

  9. bzoj 3505 [Cqoi2014]数三角形(组合计数)

    [题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=3505 [题意] 在n个格子中任选3点构成三角形的方案数. [思路] 任选3点-3点共线 ...

  10. ArcMap10.1修改要素属性字段

    ArcMap10.1修改要素属性字段 问题描述:在ArcMap10.1中编辑要素属性表时,遇到输入字段值的长度超过字段最大长度时,ArcMap会抛出“基础DBMS错误[ORA-12899:value ...