【76.83%】【codeforces 554A】Kyoya and Photobooks
time limit per test2 seconds
memory limit per test256 megabytes
inputstandard input
outputstandard output
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.
Examples
input
a
output
51
input
hi
output
76
Note
In the first case, we can make ‘ab’,’ac’,…,’az’,’ba’,’ca’,…,’za’, and ‘aa’, producing a total of 51 distinct photo booklets.
【题目链接】:http://codeforces.com/contest/554/problem/A
【题解】
枚举26个字母,再枚举这个字母要插入到哪里;
判重的时候就直接用map搞。
【完整代码】
#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define rei(x) scanf("%d",&x)
#define rel(x) scanf("%I64d",&x)
#define pri(x) printf("%d",x)
#define prl(x) printf("%I64d",x)
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
//const int MAXN = x;
const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const double pi = acos(-1.0);
string s;
map <string,int> dic;
int main()
{
//freopen("F:\\rush.txt","r",stdin);
LL ans = 0;
cin >> s;
int len = s.size();
rep1(i,1,26)
{
char ke = i+'a'-1;
rep1(j,0,len)
{
string temp = s;
string st = "";
st+=ke;
temp.insert(j,st);
if (!dic[temp])
{
dic[temp] = 1;
ans++;
}
}
}
cout << ans << endl;
return 0;
}
最新文章
- spring 多数据源一致性事务方案
- Building GCC 4.1.2 in CentOS 7 for Maya API development
- Qt MVC(模型-视图-代理)
- 第58讲:Scala中Abstract Types实战详解
- 数据库连接池的选择 Druid
- 读者写者问题(有bug 后续更改)
- Diagram of Spring 3.0 module dependencies--转载
- PHP随机生成广告图片的实例 代码
- ssh 安全配置
- WPF页面跳转
- Spring DI模式 小样例
- Linux中进行挂起(待机)的命令说明
- [Usaco2007 Jan]Running贝茜的晨练计划[一般DP]
- iis无法加载样式
- mybatis入门介绍一
- Mysql常用命令大全
- LAMP简介与部署
- linux操作系统-两台linux服务器SSH免密码登录
- Angular2 -- 生命周期钩子
- Entity Framework应用:使用Code First模式管理存储过程
热门文章
- [ Eclipse ] [ Problem ] Eclipse 無法開啟問題
- 不用浏览器,直接用代码发送文件给webservices所在服务器 并且可以周期行的发送
- golang API 例子实现
- 【Codeforces Round #451 (Div. 2) C】Phone Numbers
- java和javascript日期校验和闰年问题分析和解决方式
- iOS 友盟分享
- 前端切图|点击按钮div变色
- 【CS Round #43 D】Bad Triplet
- Dcloud课程5 php如何实现文件缓存技术(静态数据缓存)
- CSS笔记 - fgm练习 2-9 - 播放列表收缩展开