Codeforces554A:Kyoya and Photobooks

A. Kyoya and Photobooks

Time Limit: 2000ms
Memory Limit: 262144KB
64-bit integer IO format: %I64d      Java class name: (Any)

Kyoya Ootori is selling photobooks of the Ouran High School Host Club. He has 26 photos, labeled "a" to "z", and he has compiled them into a photo booklet with some photos in some order (possibly with some photos being duplicated). A photo booklet can be described as a string of lowercase letters, consisting of the photos in the booklet in order. He now wants to sell some "special edition" photobooks, each with one extra photo inserted anywhere in the book. He wants to make as many distinct photobooks as possible, so he can make more money. He asks Haruhi, how many distinct photobooks can he make by inserting one extra photo into the photobook he already has?

Please help Haruhi solve this problem.

 

Input

The first line of input will be a single string s (1 ≤ |s| ≤ 20). String s consists only of lowercase English letters.

 

Output

Output a single integer equal to the number of distinct photobooks Kyoya Ootori can make.

 

Sample Input

Input
a
Output
51
Input
hi
Output
76

Hint

In the first case, we can make 'ab','ac',...,'az','ba','ca',...,'za', and 'aa', producing a total of 51 distinct photo booklets.

 

 

题目大意:有一个英文字符串,问加一个字母,字符串有几种不同的样子。

 

思路:遍历一遍。记录一下一共有多少个a,b,c,d.....假设一共有n个a,那这个字符串插入a的话,插入在a的左边和插入a的右边是一样,假设字符串一共有len个字符,那一共有len+1个可以放,减去重复的  一共有len+1-s[i],s[i]表示第i个英文字母的个数   累加即可

 

代码:

#include <stdio.h>
#include <iostream>
#include <string.h>

using namespace std;

int main(){
    char s[30];
    int len;
    int ans=0;
    int num[26]={0};
    cin>>s;
    len = strlen(s);
    for(int i=0;i<len;i++)
        num[s[i]-'a']++;
    for(int i=0;i<26;i++)
        ans+=(len-num[i]+1);
    cout<<ans<<endl;

}

 

posted on 2016-07-12 15:03  猪是的念来过倒  阅读(109)  评论(0编辑  收藏  举报