//先按照重复次数去找出字符,然后计算即可 let str; let count = [26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1]; while(str = parseInt(readline())){ for(let i=0;i<str;i++){ let now = readline(); let obj = {} for(let temp of now.split('')) if(obj[temp]){ obj[temp] += 1; }else{ obj[temp] = 1; } let arr = []; for(let v in obj){ arr.push(obj[v]) } arr = arr.sort((a,b)=>{ return b-a; }) let a = arr.reduce((pre,cur,index)=>{ return pre+cur*count[index]; },0) console.log(a) } }