Codeforces Round #115 A. Robot Bicorn Attack 暴力
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 暴力的更多相关文章
- A - Robot Bicorn Attack
Description Vasya plays Robot Bicorn Attack. The game consists of three rounds. For each one a non-n ...
- Codeforces Round #307 (Div. 2) B. ZgukistringZ 暴力
B. ZgukistringZ Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/551/probl ...
- 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 ...
- Codeforces Round #328 (Div. 2) A. PawnChess 暴力
A. PawnChess Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/592/problem/ ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
随机推荐
- 她让我懂得了怎样学习Flash
原文:http://www.asv5.cn/blog/article.asp?id=169 最近忙着寻找两样丢失了很久的东西,都是她帮我找回来的,第一样叫做自信,第二样叫做梦想.也正因为有了她,我才从 ...
- ubuntu1204上不能正常用emacs配合gocode进行自动补全
我按gocode的页面https://github.com/nsf/gocode上去做,可是还是未成功,,我确认auto-complete在c-mode中是可以使用的,因为有补全出来了, 我再找了ht ...
- 【转】匹配dll(exe)和pdb方法
1. 静态检查windbg 调试工具包中有一个工具symchk.exe, 选项很多, 下面一个简单的用法可以检查一个 test.exe能不能找到与它匹配的PDB: 这是成功的情形. 下面来个失败的作为 ...
- hdu 3047 Zjnu Stadium(加权并查集)2009 Multi-University Training Contest 14
题意: 有一个运动场,运动场的坐席是环形的,有1~300共300列座位,每列按有无限个座位计算T_T. 输入: 有多组输入样例,每组样例首行包含两个正整数n, m.分别表示共有n个人,m次操作. 接下 ...
- [King.yue]Ext.Net 正则表达式用法
例: .Regex("^[A-Za-z0-9]+$") //正则表达式 .InvalidText("只能输入英文字符和数字.")); //输入错误提示
- Python--类使用
类使用的几个注意点: 1. 类的语法结构:2. __init__(self),3. __metaclass__=type, (新式类)4. super(subclassname, self).__in ...
- 【SQL server】安装和配置
(1)SQL sever 版本问题1: SQL sever 2000 .SQL sever 2005.SQL sever 2008 .SQL sever 2008 R2 安装的时候需要注意是SQL s ...
- <转>ERP的测试用例模板
1页面部分(1) 页面清单是否完整(是否已经将所需要的页面全部都列出来了)(2) 页面是否显示(在不同分辨率下页面是否存在,在不同浏览器版本中页面是是否显示)(3) 页面在窗口中的显示是否正确.美观( ...
- Windows安装pomelo过程
安装总要出点状况的.操作系统是win7 64bit. 为了保证顺利,打开的是VS2012命令行提示.运行 npm install -g pomelo 经过一系列输出,最后安装提示完成了.但是输入 po ...
- PHP 调用外部程序的几种方式
/* php 调用python 的代码 // 第一种: // echo passthru('C:/Python34/PY.exe D:/do.py'); // 第二种: // echo exec('C ...