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/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');elses1=s.substr(0,i)+char(j+'a')+s.substr(i,s.size());if(!H[s1]){ans++;H[s1]=1;}}}cout<<ans<<endl; }
转载于:https://www.cnblogs.com/qscqesze/p/4599068.html
Codeforces Round #309 (Div. 2) A. Kyoya and Photobooks 字符串水题相关推荐
- Codeforces Round #355 (Div. 2) B. Vanya and Food Processor 水题
B. Vanya and Food Processor 题目连接: http://www.codeforces.com/contest/677/problem/B Description Vanya ...
- Codeforces Round #331 (Div. 2) A. Wilbur and Swimming Pool 水题
A. Wilbur and Swimming Pool Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/conte ...
- Codeforces Round #694 (Div. 1 + Div2)(A ~ H,8题全,超高质量题解)【每日亿题】2021/2/1、2/2
整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 目录 [每日亿题]Codeforces Round #694 (Div. 1 + Div2)(A ~ ...
- Codeforces Round #592 (Div. 2) G. Running in Pairs 构造(水)
传送门 文章目录 题意: 思路: 题意: 思路: 史上最水GGG题,没有之一. 考虑最小的情况如何构造,显然就是让a,ba,ba,b都1−n1-n1−n依次排列即可,这样的最小值为n∗(n+1)2\f ...
- Codeforces Round #632 (Div. 2) E. Road to 1600 构造好题
传送门 文章目录 题意: 思路 题意: 直接白嫖 思路 首先不难发现,n≤2n\le2n≤2的时候是无解的. 现在我们来构造n=3n=3n=3的情况,通过打表可以发现如下矩阵是符合题目要求的: 179 ...
- Codeforces Round #309 (Div. 1)D. Nudist Beach 二分+bfs
题目:http://codeforces.com/contest/553/problem/D 在一个无向图中,有若干坏点,选择一个不包含坏点的集合,使得集合中p值最小的点的p值最大.一个点的p值=集合 ...
- Codeforces Round #309 (Div. 1)
A. Kyoya and Colored Balls 大意: 给定$k$种颜色的球, 第$i$种颜色有$c_i$个, 一个合法的排列方案满足最后一个第$i$种球的下一个球为第$i+1$种球, 求合法方 ...
- Codeforces Round #309 (Div. 2) C
题意: 就是给出总共同拥有k种颜色.每种颜色有ki种,排列必须满足第i+1种的最后一种颜色必须在第i种最后一种颜色的后面,其它颜色任意.总共同拥有多少种排列点的方法. 分析: 如果d[i]表示前i种的 ...
- Codeforces Round #351 (VK Cup 2016 Round 3, Div. 2 Edition) A. Bear and Game 水题
A. Bear and Game 题目连接: http://www.codeforces.com/contest/673/problem/A Description Bear Limak likes ...
最新文章
- Rocksdb 的优秀代码(三)-- 工业级 线程池实现分享
- 防止sql注入的方式php,探讨php中防止SQL注入最好的方法是什么
- 笔记-信息系统安全管理-信息系统安全等级保护基本要求
- access 打印预览 代码_标签打印软件如何批量打印样品标签
- 用栈来求解汉诺塔变形问题
- spark入门_入门必读 | Spark 论文导读
- 【MFC系列-第11天】CWinApp类成员分析
- 在虚拟机上运行vxWorks
- C++--第13课 - 操作符重载 - 下
- 文字表情 emoji 解析大全
- 计算机ppt听课记录,怎样做好听课记录.ppt
- 开服当GM的基本准则
- Python 加性高斯白噪声 AWGN
- 2022京东3.8节如何给不同SKU打水印?
- 写给女儿青春生日的信(转载)
- 手机淘宝APP关键词搜索采集方案
- 如何免费将PDF转成JPG?
- [OGRE]基础教程来三发:来谈一谈摄像机吧
- Android多点触控之——MotionEvent(触控事件)
- php实用吗,php实用小窍门