vsftp安装脚本
2012-04-17 13:44
106 查看
Problem Statement | ||||||||||||
A common task for math students is to solve 'word math' questions, where each distinct letter represents a distinct digit. Given a list of word math numbers to add, your task is to calculate the greatest possible sum of those numbers. For example, given the expression: TOP + CODER the maximum sum possible by substituting numbers is: 783 + 98654 ------- 99437 with C = 9, D = 6, E = 5, O = 8, P = 3, R = 4 and T = 7. Please note that, for this question, word math numbers are allowed to start with a zero. | ||||||||||||
Definition | ||||||||||||
| ||||||||||||
Notes | ||||||||||||
- | Different letters must represent different digits, identical letters must represent identical digits. | |||||||||||
- | Not all digits in the result must appear in the summands. | |||||||||||
Constraints | ||||||||||||
- | summands will contain between 1 and 10 elements, inclusive. | |||||||||||
- | Each element of summands will contain between 1 and 8 characters, inclusive. | |||||||||||
- | Each element of summands will contain only uppercase letters ('A'-'Z'). | |||||||||||
- | summands will contain at most 10 distinct letters. | |||||||||||
Examples | ||||||||||||
0) | ||||||||||||
| ||||||||||||
1) | ||||||||||||
| ||||||||||||
2) | ||||||||||||
| ||||||||||||
3) | ||||||||||||
| ||||||||||||
4) | ||||||||||||
|
import java.util.Arrays; public class WordMath { int[] weigh = new int[26]; public int maximumSum(String[] summands) { for (String s : summands) for (int j = 0, n = s.length(); j < n; j++) weigh[s.charAt(j) - 'A'] += Math.pow(10, n - j - 1); Arrays.sort(weigh); int ret = 0; for (int i = 0; i < 10; i++) ret += weigh[25 - i] * (9 - i); return ret; } }
相关文章推荐
- Shell脚本一键安装VSFTP
- linux——安装vsftp及配置虚拟匿名用户脚本
- vsftp安装 shell脚本
- Vsftp 自动化安装脚本
- CentOS7一键安装vsftp脚本
- CentOS6一键安装vsftp脚本
- vsftp安装脚本
- Lua + GraphicsMagick安装 (第二种的lua脚本)
- sps & wss 下webpart 的安装脚本
- openstack devstack 脚本安装(多结点,控制结点安装)
- centos安装vsftp ftp服务端
- Linux环境编写脚本安装配置JDK,Tomcat,含Tomcat自启动
- vsftp简单安装
- Weblogic安装部署建域全过程-图形加脚本
- 记帮同事解决vsftp安装后无法启动的过程
- [shell]为CentOS创建自动安装模块的脚本
- Inno Setup 脚本实例——选择安装:当前用户、所有用户
- redhat 下安装jdk的shell脚本
- 使用PyInstaller2将Python脚本转化为可执行文件(上-安装部分)
- MySQL技术之旅--MySQL自动安装脚本