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. C 的 coroutine 库 via 云风的 BLOG

    今天实现了一个 C 用的 coroutine 库. 我相信这个东西已经被无数 C 程序员实现过了, 但是通过 google 找了许多, 或是接口不让我满意, 或是过于重量. 在 Windows 下, ...

  2. JS:实用功能

    ylbtech-jQuery:函数-导航 添加样式(addClass).移除样式(removeClass) 轮替函数(toggle()) 选项拼加 全选 网页刷点器 jQuery:3.1,添加样式(a ...

  3. mysql DDL语句

    sql语言分为三个级别. 1.ddl 语句 ,数据定义语句,定义了数据库.表.索引等对象的定义.常用语句包含:create.drop.alter. 2.dml 语句 ,数据操纵语句,用于添加.删除.更 ...

  4. 【LeetCode 230】Kth Smallest Element in a BST

    Given a binary search tree, write a function kthSmallest to find the kth smallest element in it. Not ...

  5. Windows套接字Socket函数

    1.使用套接字函数之前,先要加载套接字函数库: #include "Winsock2.h" #pragma comment(lib,"Ws2_32.lib") ...

  6. NGUI的UIProgressBar使用裁剪方式而不是压缩方式的方法

    UIProgressBar默认的方式是压缩图片,而如果我们需要裁减图片,只需要将UIProgressBar的Foreground的UISprite的Type改为Filled就行了. 好几个“的”... ...

  7. Activity的活动周期

    Android 使用task来管理Activity.是一个栈的形式.遵循后进先出原则. Activity的四种状态: 运行状态(用户可以操作该Activity).暂停状态(用户可见该Activity, ...

  8. <Chapter 2>2-2-2.开发Java应用(Developing a Java App)

    App Engine的Java网络应用使用了Java Servlet标准接口来和应用服务器交互.一个应用由一个或多个servlet类组成,每个都扩展了(extend)servlet基类.使用一个叫做部 ...

  9. 【Hadoop代码笔记】Hadoop作业提交之Child启动map任务

    一.概要描述 在上篇博文描述了TaskTracker启动一个独立的java进程来执行Map或Reduce任务.在本篇和下篇博文中我们会关注启动的那个入口是org.apache.hadoop.mapre ...

  10. 关于tomcat不支持put方式的解决方式

    在jetty中是支持put方式操作的,在tomcat中默认是不支持的,解决方式很简单,在web.xml中添加一个过滤器即可. <filter> <filter-name>htt ...