水题:P2799 国王的魔镜】的更多相关文章

思路:简单模拟即可.判断一下是不是回文,是回文看长度是不是偶数.是偶数的话,说明又可能是回文.依次这样处理.但是只要长度为奇数则一定是原来的长度直接输出即可. #include<iostream> #include<cstring> using namespace std; + ; char num[maxn]; bool flag(int x){ , q = x-; while (p < q&&num[p] == num[q]){ ++p; --q; } ;…
P2799 国王的魔镜 题目描述 国王有一个魔镜,可以把任何接触镜面的东西变成原来的两倍——只是,因为是镜子嘛,增加的那部分是反的.比如一条项链,我们用AB来表示,不同的字母表示不同颜色的珍珠.如果把B端接触镜面的话,魔镜会把这条项链变为ABBA.如果再用一端接触的话,则会变成ABBAABBA(假定国王只用项链的某一端接触魔镜).给定最终的项链,请编写程序输出国王没使用魔镜之前,最初的项链可能的最小长度. 输入输出格式 输入格式: 只有一个字符串,由大写英文字母组成(字母数<=100000),表…
把项链当做字符串输进去,可以用gets #include<iostream>#include<cstdio>#include<cmath>#include<cstring>using namespace std;char a[100000];int fj(int);int main(){         gets(a);         int len=strlen(a);         fj(len);         return 0; }int fj…
链接 想了好久(蒟蒻的不能蒟蒻) 题解: #include<iostream>#include<cstdio>#include<cstring>#include<cmath>using namespace std;char c[100001];int m,n;bool b=1;void an(){ if(b==1) {if(m%2==1) {cout<<m;b=0;}//若长度为奇数,输出 if(m%2==0) { for(int i=0;i&l…
http://www.lydsy.com/JudgeOnline/problem.php?id=3850 题意:类似国王游戏....无意义.. #include <cstdio> #include <cstring> #include <cmath> #include <string> #include <iostream> #include <algorithm> #include <queue> #include &l…
Nasty Hacks Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 3049    Accepted Submission(s): 2364 Problem Description You are the CEO of Nasty Hacks Inc., a company that creates small pieces of…
CSU 1772 漫漫上学路 Time Limit: 1000MS   Memory Limit: 131072KB   64bit IO Format: %lld & %llu Submit Status Description 对于csuxushu来说,能够在CSU(California State University)上学是他一生的荣幸.CSU校园内的道路设计的十分精巧,由n+1条水平道路和n+1条竖直道路等距交错而成,充分体现了校园深厚的文化底蕴.然而不幸的是CS市每到夏季,天降大雨,…
1050: 写一个函数,使给定的一个二维数组(3×3)转置,即行列互换 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 154  Solved: 112[Submit][Status][Web Board] Description 写一个函数,使给定的一个二维数组(3×3)转置,即行列互换. Input 一个3x3的矩阵 Output 转置后的矩阵 Sample Input 1 2 3 4 5 6 7 8 9 Sample Output 1 4 7…
DP 水题 Description A number whose only prime factors are 2,3,5 or 7 is called a humble number. The sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 24, 25, 27, ... shows the first 20 humble numbers. Write a program to find and print…
1195: 相信我这是水题 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 821  Solved: 219 Description GDUT中有个风云人物pigofzhou,是冰点奇迹队的主代码手,萌萌的师弟师妹们们经常会让pigofzhou帮他们Debug,因为师弟师妹们打代码使用编程语言的种类千奇百怪,pigofzhou为此很头疼.现在假设师弟师妹们只喜欢Java或者C++或者C,因为他希望所有人都学相同的编程语言,只有这样pigofzhou教…