Time Limit: 20 Sec
Memory Limit: 256 MB
题目连接
http://codeforces.com/contest/554/problem/A
Description
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
a
Sample Output
51
HINT
题意
给你一个字符串,然后让你随便在一个位置加上一个字母,问你能够产生多少个不同的字符串
题解:
暴力加字符串,然后用map判重就好了
代码
//qscqesze #include <cstdio> #include <cmath> #include <cstring> #include <ctime> #include <iostream> #include <algorithm> #include <set> #include <vector> #include <sstream> #include <queue> #include <typeinfo> #include <fstream> #include <map> #include <stack> typedef long long ll; using namespace std; //freopen("D.in","r",stdin); //freopen("D.out","w",stdout); #define sspeed ios_base::sync_with_stdio(0);cin.tie(0) #define maxn 200001 #define mod 10007 #define eps 1e-9 int Num; char CH[20]; //const int inf=0x7fffffff; //нчоч╢С const int inf=0x3f3f3f3f; /* inline void P(int x) { Num=0;if(!x){putchar('0');puts("");return;} while(x>0)CH[++Num]=x%10,x/=10; while(Num)putchar(CH[Num--]+48); puts(""); } */ inline ll read() { int x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f; } inline void P(int x) { Num=0;if(!x){putchar('0');puts("");return;} while(x>0)CH[++Num]=x%10,x/=10; while(Num)putchar(CH[Num--]+48); puts(""); } //************************************************************************************** map<string,int> H; int main() { string s; cin>>s; int ans=0; for(int i=0;i<=s.size();i++) { for(int j=0;j<26;j++) { string s1; if(i==0) s1=char(j+'a')+s; else if(i==s.size()) s1=s+char(j+'a'); else s1=s.substr(0,i)+char(j+'a')+s.substr(i,s.size()); if(!H[s1]) { ans++; H[s1]=1; } } } cout<<ans<<endl; }