Codeforces554A:Kyoya and Photobooks
A. Kyoya and Photobooks
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
a
51
hi
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[];
int len;
int ans=;
int num[]={};
cin>>s;
len = strlen(s);
for(int i=;i<len;i++)
num[s[i]-'a']++;
for(int i=;i<;i++)
ans+=(len-num[i]+);
cout<<ans<<endl; }
Codeforces554A:Kyoya and Photobooks的更多相关文章
- Codeforces Round #309 (Div. 2) A. Kyoya and Photobooks 字符串水题
A. Kyoya and Photobooks Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/5 ...
- A. Kyoya and Photobooks(Codeforces Round #309 (Div. 2))
A. Kyoya and Photobooks Kyoya Ootori is selling photobooks of the Ouran High School Host Club. He ...
- 找规律 Codeforces Round #309 (Div. 2) A. Kyoya and Photobooks
题目传送门 /* 找规律,水 */ #include <cstdio> #include <iostream> #include <algorithm> #incl ...
- Codeforces Round #309 (Div. 2) A. Kyoya and Photobooks【*组合数学】
A. Kyoya and Photobooks time limit per test 2 seconds memory limit per test 256 megabytes input stan ...
- 【76.83%】【codeforces 554A】Kyoya and Photobooks
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- Codeforces Round #309 (Div. 2)
A. Kyoya and Photobooks Kyoya Ootori is selling photobooks of the Ouran High School Host Club. He ha ...
- Codeforces554 C Kyoya and Colored Balls
C. Kyoya and Colored Balls Time Limit: 2000ms Memory Limit: 262144KB 64-bit integer IO format: %I64d ...
- codeforces 553A . Kyoya and Colored Balls 组合数学
Kyoya Ootori has a bag with n colored balls that are colored with k different colors. The colors are ...
- Codeforces Round #309 (Div. 1) B. Kyoya and Permutation 构造
B. Kyoya and Permutation Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/ ...
随机推荐
- WebService的创建发布及部署
1.打开win7的IIS功能: http://jingyan.baidu.com/article/2a138328ae4b85074b134f55.html 2.IIS注册Frameworkt4.0 ...
- [Linux]使用PHP编写Gearman的Worker守护进程
在我之前的文章中,介绍过Gearman的使用.在我的项目中,我使用了PHP来编写一直运行的Worker.如果按照Gearman官方推荐的例子,只是简单的一个循环来等待任务,会有一些问题,包括:1.当代 ...
- 前端小知识(转载http://www.cnblogs.com/Wayou/p/things_you_dont_know_about_frontend.html)
前端已经被玩儿坏了!像console.log()可以向控制台输出图片等炫酷的玩意已经不是什么新闻了,像用||操作符给变量赋默认值也是人尽皆知的旧闻了,今天看到Quora上一个帖子,瞬间又GET了好多前 ...
- mac下剪切文件或文件夹
首先选中文件,按Command+C复制文件:然后按Command+Option+V:就可以把你的文件剪走了!
- IIS跳转html页面自动识别是PC端还是手机端
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- jq表头固定
<!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <meta na ...
- iOS - 模拟器
模拟器分为ipad模拟器和iphone模拟器,尺寸都是固定的,就是320*480(iphone),640*960(iphone高清)1024*768(ipad),目前这个尺寸是不能调的.
- LATTICE USB下载线接口说明
这节知识摘抄于网络,仅用几张图片来显示,提醒Usb下载线的连接方式. 最后贴出个人使用的8线的USB下载器的连接方式: 再补充一点,应为彩色杜邦线与USB下载器是活口连接,两个可以分开,再连接的时候, ...
- PLSQL Develop PlugIn 之脚本自动匹配补全工具CnPlugin
插件位置:百度云 -- 开发工具空间 -- CnPlugin CnPlugin 支持PL/sql Developer 7.0以上版本,它可以根据 关键字+tab/space 来触发代码补全,而关键字. ...
- Hibernate Open Session In View模式【转】
来源:http://www.yybean.com/opensessioninviewfilter-role-and-configuration 一.作用 Spring为我们解决Hibernate的Se ...