题解 | #编码#
编码
http://www.nowcoder.com/practice/6fc8716ee33e4cc59d58d7e18712094e
import java.util.*;
public class Main{
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
char[] s = cin.next().toCharArray();
int n = s.length;
//用curSum来保存已有计算结果
//sum计算4种情况之和
int sum = 0, curSum = 0;
for (int i = 0; i < 4; ++i) {
if (i < n) {
curSum += s[i] - 'a'; //我们把序列分成26块,从a-y开始的块
}
sum += curSum;
if (i < n - 1) {
sum += 1;
}
curSum *= 25;
}
System.out.println(sum);
cin.close();
}
}