719
来源:互联网 发布:论文查重率软件 编辑:程序博客网 时间:2024/06/04 01:15
2017.10.24
当遍历到s的第i个字符时 d[i] = max(i*d[i-1], i+ d[i-1])
public class Solution { /* * @param : the given string * @return: the maximum value */ public int calcMaxValue(String str) { // write your code hereif(str.length() == 0){return 0;}if(str.length() == 1){return Integer.valueOf(str);}int a = Integer.valueOf(str.substring(0,1));int b = Integer.valueOf(str.substring(1,2));int res = Math.max(a+b, b*a);if(str.length() == 2){return res;}for(int i = 2; i < str.length(); i++){ int tmp = Integer.valueOf(str.substring(i,i+1));//System.out.print("tmp = " + tmp + ";旧res = " + res);res = Math.max(tmp+res, tmp*res);//System.out.println(";新res = " + res);}return res; }};
阅读全文
0 0
- 719
- uva 719 glass beads
- codeforce 719b 贪心
- Codeforce 719B
- Codeforces 719C
- CodeForces 719B
- codeforces 719A 【python】
- Thinstall v2.719 by Jitit
- uva 719 - Glass Beads(后缀自动机)
- UVA 719 - Glass Beads (最小表示法)
- uva 719 Glass Beads (后缀自动机)
- UVA 719(后缀自动机/最小表示法)
- NEUOJ 719 (字典树 字典序)
- Codeforces 719B B. Anatoly and Cockroaches
- 【31.58%】【codeforces 719B】 Anatoly and Cockroaches
- Codeforces 719A-Vitya in the Countryside
- codeforces 719C. Efim and Strange Grade
- CodeForces 719 A. Vitya in the Countryside
- H5语义化标签笔记库
- XML学习04-Java中DOM方式解析XML文件
- 爬虫实战(整站爬虫新浪新闻,并按照递归路径存储在本地)
- 系统开发
- 速度超快-韩国vps推荐
- 719
- ReactNative开发安卓环境搭建(坑)
- 【已解决】Git配置本地与远程库连接报错:fatal: Not a git repository (or any of the parent directories): .git
- 大数据测试方法详解
- Python高级特性
- 160个练手CrackMe-011
- 链表 归并
- web server(web服务器)简单了解
- 10.18 取数 2434