题目传送门

 /*
水题:vector容器实现插入操作,暴力进行判断是否为回文串
*/
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
using namespace std; const int MAXN = 1e4 + ;
const int INF = 0x3f3f3f3f;
vector<char> s;
char ss[]; bool check(void)
{
for (int i=, j=s.size ()-; i<j; ++i, --j)
if (s[i] != s[j]) return false;
return true;
} int main(void) //Codeforces Round #286 (Div. 2) A Mr. Kitayuta's Gift
{
//freopen ("A.in", "r", stdin); while (cin >> ss)
{
s.clear (); bool flag = false;
for (int i=; ss[i]; ++i) s.push_back (ss[i]);
for (int i=; i<=s.size (); ++i)
{
for (int j=; j<=; ++j)
{
char ch = 'a' + j;
s.insert (s.begin () + i, ch);
if (check ())
{
flag = true;
for (int i=; i<s.size (); ++i)
cout << s[i];
cout << endl; break;
}
else s.erase (s.begin () + i);
}
if (flag) break;
} if (!flag) cout << "NA" << endl;
} return ;
}

 #include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
using namespace std; const int MAXN = 1e4 + ;
const int INF = 0x3f3f3f3f; bool ok(string x)
{
string ss = x;
reverse (ss.begin (), ss.end ());
return (ss == x);
} int main(void) //Codeforces Round #286 (Div. 2) A Mr. Kitayuta's Gift
{
//freopen ("A.in", "r", stdin); string s;
cin >> s; int len = s.size ();
for (int i=; i<=len; ++i)
{
for (char c='a'; c<='z'; ++c)
{
string x;
for (int j=; j<i; ++j) x += s[j];
x += c;
for (int j=i; j<len; ++j) x += s[j];
if (ok (x)) {cout << x << endl; return ;}
}
}
cout << "NA" << endl; return ;
}

string 实现

水题 Codeforces Round #286 (Div. 2) A Mr. Kitayuta's Gift的更多相关文章

  1. Codeforces Round #286 (Div. 2)A. Mr. Kitayuta's Gift(暴力,string的应用)

    由于字符串的长度很短,所以就暴力枚举每一个空每一个字母,出现行的就输出.这么简单的思路我居然没想到,临场想了很多,以为有什么技巧,越想越迷...是思维方式有问题,遇到问题先分析最简单粗暴的办法,然后一 ...

  2. DFS/并查集 Codeforces Round #286 (Div. 2) B - Mr. Kitayuta's Colorful Graph

    题目传送门 /* 题意:两点之间有不同颜色的线连通,问两点间单一颜色连通的路径有几条 DFS:暴力每个颜色,以u走到v为结束标志,累加条数 注意:无向图 */ #include <cstdio& ...

  3. Codeforces Round #286 (Div. 1) D. Mr. Kitayuta's Colorful Graph 并查集

    D. Mr. Kitayuta's Colorful Graph Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/ ...

  4. Codeforces Round #286 (Div. 1) B. Mr. Kitayuta&#39;s Technology (强连通分量)

    题目地址:http://codeforces.com/contest/506/problem/B 先用强连通判环.然后转化成无向图,找无向图连通块.若一个有n个点的块内有强连通环,那么须要n条边.即正 ...

  5. Codeforces Round #286 Div.1 A Mr. Kitayuta, the Treasure Hunter --DP

    题意:0~30000有30001个地方,每个地方有一个或多个金币,第一步走到了d,步长为d,以后走的步长可以是上次步长+1,-1或不变,走到某个地方可以收集那个地方的财富,现在问走出去(>300 ...

  6. Codeforces Round #286 (Div. 2) B. Mr. Kitayuta's Colorful Graph dfs

    B. Mr. Kitayuta's Colorful Graph time limit per test 1 second memory limit per test 256 megabytes in ...

  7. Codeforces Round #286 (Div. 1) D. Mr. Kitayuta's Colorful Graph

    D - Mr. Kitayuta's Colorful Graph 思路:我是暴力搞过去没有将答案离线,感觉将答案的离线的方法很巧妙.. 对于一个不大于sqrt(n) 的块,我们n^2暴力枚举, 对于 ...

  8. Codeforces Round #286 (Div. 2)B. Mr. Kitayuta's Colorful Graph(dfs,暴力)

    数据规模小,所以就暴力枚举每一种颜色的边就行了. #include<iostream> #include<cstdio> #include<cstdlib> #in ...

  9. 水题 Codeforces Round #302 (Div. 2) A Set of Strings

    题目传送门 /* 题意:一个字符串分割成k段,每段开头字母不相同 水题:记录每个字母出现的次数,每一次分割把首字母的次数降为0,最后一段直接全部输出 */ #include <cstdio> ...

随机推荐

  1. STL review:vector & string & map & struct

    I.vector 1.头文件:#include<vector>                        //容器vector是一个能实现随机存取.插入删除的动态数组,还可以当栈使. ...

  2. MIPS 指令集将在近期开源,RISC-V 阵营慌吗?

    消息称,MIPS 指令集即将开源. eetimes 17 日报导,Wave Computing 公司表示,在明年第一季度发布最新 MIPS 指令集体系和 MIPS 最新内核 R6 的时候将开源 MIP ...

  3. ros使用时的注意事项&技巧2

    1.查看参数列表 rosparam list 2.查询参数rosparam get parameter_name,如rosparam get /rosdistro 3.设置参数rosparam set ...

  4. SCX-4521F一体机MAC驱动

    如果您想下载SCX-4521F一体机MAC驱动,请从下面的链接中下载相应驱动:MAC打印驱动:http://org.downloadcenter.samsung.com/downloadfile/Co ...

  5. maven实战(3)-- dependency <classifier>的使用

    Maven 的classifier的作用 转自:http://blog.csdn.net/lovingprince/article/details/5894459 直接看一个例子,maven中要引入j ...

  6. bzoj 2238 Mst —— 树剖+mn标记永久化

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2238 看了半天... 首先,想要知道每条边删除之后的替代中最小的那个: 反过来看,每条不在 ...

  7. 【转】设置cocos2dx 屏幕分辨率

    [转载连接:]http://www.cnblogs.com/onlycxue/p/3500026.html 做手机上的软件首先要考虑的就是屏幕分辨率怎么解决.coco2dx已经有了很好的解决方法. 用 ...

  8. Bug: CCScheduler#scheduleSelector. Selector already scheduled. Updating interval from: 0.0000 to 0.0000

    原因是当前的scheduleOnce还没有执行完成, 可以将scheduleOnce方法改写成另外一种形式,把CCDelayTime和CCCallFunc拼接构造延迟事件调用: CCDelayTime ...

  9. HDU-5551 Huatuo's Medicine

    Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submission( ...

  10. HDU 1270 小希的数表 (暴力枚举+数学)

    题意:... 析:我们可以知道,a1+a2=b1,那么我们可以枚举a1,那么a2就有了,并且a1+a3=b2,所以a3就有了,我们再从把里面的剩下的数两两相加,并从b数组中去掉, 那么剩下的最小的就是 ...