CodeForces 688B-Lovely Palindromes
题意:
给出一串数字,要你输出它的回文数,就这么简单.
分析:
可以用数组去做,也可以用reversed()函数(这个更简单).
代码如下:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <ctime>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <iterator>z
#include <vector> using namespace std; #define LL long long
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define MAXN 10000010
#define MAXM 1000010 const int maxn = ;
int a[maxn]; int main()
{
string s;
while(cin>>s)
{
memset(a, , sizeof(a));
int i;
int len = s.size();
int c = ;
for(i = ; i < len; i++ )
a[c++] = s[i] - '';
int b = ;
for(i = *c-; i >= c; i-- )
a[i] = a[b++];
for(i = ; i < *c; i++ )
printf("%d", a[i]);
printf("\n");
} return ;
}
#include <iostream>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <ctime>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <iterator>z
#include <vector> using namespace std; #define LL long long
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define MAXN 10000010
#define MAXM 1000010 int main()
{
string s;
cin >> s;
cout << s;
reverse(s.begin(), s.end()); //将字符串s中的顺序颠倒
cout << s << endl;
}
CodeForces 688B-Lovely Palindromes的更多相关文章
- CodeForces 688B Lovely Palindromes (水题回文)
题意:给一个数n,让你找出长度为偶数,并且是第 n 个回文数. 析:你多写几个就知道了,其实就是 n,然后再加上n的逆序,不过n有点大,直接用string 好了. 代码如下: #include < ...
- codeforces 688B B. Lovely Palindromes(水题)
题目链接: B. Lovely Palindromes time limit per test 1 second memory limit per test 256 megabytes input s ...
- Codeforces Round #360 (Div. 2) B. Lovely Palindromes 水题
B. Lovely Palindromes 题目连接: http://www.codeforces.com/contest/688/problem/B Description Pari has a f ...
- CodeForces 1251B --- Binary Palindromes
[CodeForces 1251B --- Binary Palindromes] Description A palindrome is a string t which reads the sam ...
- E - Lovely Palindromes
Description Pari has a friend who loves palindrome numbers. A palindrome number is a number that rea ...
- CF688B Lovely Palindromes 题解
Content 输入一个数 \(n\),输出第 \(n\) 个偶数位回文数. 数据范围:\(1\leqslant n\leqslant 10^{10^5}\). Solution 一看这吓人的数据范围 ...
- cf688B-Lovely Palindromes
http://codeforces.com/problemset/problem/688/B B. Lovely Palindromes time limit per test 1 second me ...
- 套题 codeforces 360
A题:Opponents 直接模拟 #include <bits/stdc++.h> using namespace std; ]; int main() { int n,k; while ...
- Codeforces Round #360 div2
Problem_A(CodeForces 688A): 题意: 有d天, n个人.如果这n个人同时出现, 那么你就赢不了他们所有的人, 除此之外, 你可以赢他们所有到场的人. 到场人数为0也算赢. 现 ...
- dp --- Codeforces 245H :Queries for Number of Palindromes
Queries for Number of Palindromes Problem's Link: http://codeforces.com/problemset/problem/245/H M ...
随机推荐
- 关于SQL Server无法查询中文的问题
SQL Server 的版本是2016,随便试了一条 带有 where 子句的查询.如下: select * from Roles where RoleName like '%系统%' 呐尼,怎么一条 ...
- Linux 的字符串截取方法(转)
Linux 的字符串截取很有用.有八种方法. 假设有变量 var=http://www.aaa.com/123.htm. 1. # 号截取,删除左边字符,保留右边字符. echo ${var#*//} ...
- Linux应用程序访问字符设备驱动详细过程【转】
本文转载自:http://blog.csdn.net/coding__madman/article/details/51346532 下面先通过一个编写好的内核驱动模块来体验以下字符设备驱动 可以暂时 ...
- redis入侵
一.前言 前段时间,在做内网影响程度评估的时候写了扫描利用小脚本,扫描后统计发现,内网中60%开放了redis6379端口的主机处于可以被利用的危险状态,因为都是一些默认配置造成的考虑到本社区大部分开 ...
- Linux之常用快捷键
tab:自动补齐命令或者路径 ESC+u:将字符小写变大写 ctrl+s:在终端中冻结stdin ctrl+q:在终端中恢复stdin ctrl+a:光标移动到行首 ctrl+e:光标移动到行尾 ct ...
- 思科Cisco 2960系列交换机配置命令
配置密码: 2960>en :第一次密码为空 2960h#conf t :进入全局配置模式 2960(config)#hostname swa :设置交换机名 2960(config)#enab ...
- linux环境下安装mysql数据库遇到的问题
总结一句话: 安装完mysql数据库记得授权远程登录. 坑的现象: ERROR 1045 (28000): Access denied for user 'guoxp'@'localhost' ( ...
- 理解JS回调函数
我们经常会用到客户端与Web项目结合开发的需求,那么这样就会涉及到在客户端执行前台动态脚本函数,也就是函数回调,本文举例来说明回调函数的过程. 首先创建了一个Web项目,很简单的一个页面,只有一个bu ...
- 《BI那点儿事》数据流转换——排序
排序转换允许对数据流中的数据按照某一列进行排序.这是五个常用的转换之一.连接数据源打开编辑界面,编辑这种任务.不想设置为排序列的字段不要选中,默认情况下所有列都会选中.如图所示,按照TotalSuga ...
- 《BI那点儿事》三国人物智力分布状态分析
献给广大的三国爱好者们,希望喜欢三国的朋友一起讨论,加深对传奇三国时代的了解数据分析基础概念:数据分为“不可测量”的数据和“可测量”的数据.不可测量的数据称为“分类数据”(Category Data或 ...