CF410div2 A. Mike and palindrome

 1 /*
 2  CF410div2 A. Mike and palindrome
 3  http://codeforces.com/contest/798/problem/A
 4  水题
 5  */
 6 #include <cstdio>
 7 #include <algorithm>
 8 #include <cstring>
 9 #include <cmath>
10 #include <vector>
11 #include <queue>
12 #include <iostream>
13 #include <map>
14 #include <set>
15 //#define test
16 using namespace std;
17 const int Nmax=1e6+7;
18 char s[100];
19 char tmp[100];
20 int n;
21 int check()
22 {
23     for(int i=0;i<n;i++)
24         if(s[i]!=s[n-i-1])
25             return 0;
26     return 1;
27 }
28 int main()
29 {
30     #ifdef test
31     #endif
32     scanf("%s",tmp);
33     n=strlen(tmp);
34     int flag=0;
35     for(int i=0;i<n;i++)
36         s[i]=tmp[i];
37     if(n&1)
38     {
39         if(check())
40         {
41             printf("YES\n");
42             return 0;
43         }
44     }
45     for(int i=0;i<n;i++)
46     {
47         for(int j=0;j<n;j++)
48             s[j]=tmp[j];
49         if(s[i]==s[n-i-1])
50             continue;
51         else
52         {
53             s[i]=s[n-i-1];
54             if(check())
55                 flag=1;
56         }
57     }
58     if(flag)
59         printf("YES\n");
60     else
61         printf("NO\n");
62     return 0;
63 }

 

转载于:https://www.cnblogs.com/BBBob/p/6751671.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值