cf688B-Lovely Palindromes
http://codeforces.com/problemset/problem/688/B
1 second
256 megabytes
Pari has a friend who loves palindrome numbers. A palindrome number is a number that reads the same forward or backward. For example 12321, 100001 and 1 are palindrome numbers, while 112 and 1021 are not.
Pari is trying to love them too, but only very special and gifted people can understand the beauty behind palindrome numbers. Pari loves integers with even length (i.e. the numbers with even number of digits), so she tries to see a lot of big palindrome numbers with even length (like a 2-digit 11 or 6-digit 122221), so maybe she could see something in them.
Now Pari asks you to write a program that gets a huge integer n from the input and tells what is the n-th even-length positive palindrome number?
The only line of the input contains a single integer n (1 ≤ n ≤ 10100 000).
Print the n-th even-length palindrome number.
1
11
10
1001
The first 10 even-length palindrome numbers are 11, 22, 33, ... , 88, 99 and 1001.
题意:找第n个偶数位数的对称数字。
思路:逻辑分析题。只看数字的一半(因为是偶数位数),它的一半是n,则它就是第n个符合要求的数。
代码:
#include <iostream>
#include <cstring>
using namespace std; #define n 100005 int main ()
{
char s[n];
cin >> s;
int len = strlen(s);
for (int i = ; i < len; i++)
{
cout << s[i];
}
for (int i = len - ; i >= ; i--)
{
cout << s[i];
}
cout << endl;
return ;
}
cf688B-Lovely Palindromes的更多相关文章
- CF688B Lovely Palindromes 题解
Content 输入一个数 \(n\),输出第 \(n\) 个偶数位回文数. 数据范围:\(1\leqslant n\leqslant 10^{10^5}\). Solution 一看这吓人的数据范围 ...
- 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 688B B. Lovely Palindromes(水题)
题目链接: B. Lovely Palindromes time limit per test 1 second memory limit per test 256 megabytes input s ...
- CodeForces 688B Lovely Palindromes (水题回文)
题意:给一个数n,让你找出长度为偶数,并且是第 n 个回文数. 析:你多写几个就知道了,其实就是 n,然后再加上n的逆序,不过n有点大,直接用string 好了. 代码如下: #include < ...
- E - Lovely Palindromes
Description Pari has a friend who loves palindrome numbers. A palindrome number is a number that rea ...
- 套题 codeforces 360
A题:Opponents 直接模拟 #include <bits/stdc++.h> using namespace std; ]; int main() { int n,k; while ...
- UVA - 11584 Partitioning by Palindromes[序列DP]
UVA - 11584 Partitioning by Palindromes We say a sequence of char- acters is a palindrome if it is t ...
- hdu 1318 Palindromes
Palindromes Time Limit:3000MS Memory Limit:0KB 64bit ...
- dp --- Codeforces 245H :Queries for Number of Palindromes
Queries for Number of Palindromes Problem's Link: http://codeforces.com/problemset/problem/245/H M ...
随机推荐
- TCP 3次握手建立连接
TCP 3次握手建立连接 1. (Client) –> [SYN] –> (Server) 假如Client和Server通讯. 当Client要和Server通信时,Client首先 ...
- js 读取json数据 挖坑
一般遇到后台给的json数据格式不对 比如key和value都是单引号. 但真正的json 的key和value都是双引号,必须双引号才能取值. 再来一个例子看看 var test = [{ &quo ...
- xml获取指定节点的路径
引用自http://www.w3school.com.cn/xpath/xpath_syntax.asp XPath 语法 Previous Page Next Page XPath 使用路径表达式来 ...
- Uva1401(字典树)
1401 - Remember the Word Time limit: 3.000 seconds Neal is very curious about combinatorial problems ...
- java web工程启动socket服务
1.新建web工程 2.自定义类 实现ServletContextListener 接口 在contextInitialized方法中启动socket服务的线程 在contextDestroyed方法 ...
- XE7 - ListView自测笔记
这两天主要是摸索着使用了ListView和SQLite.郁闷过,也有收获. 一.SQLite 首先记录下SQLite自己碰到的几个小问题: 1. SQLite中字符串连接符是‘||’, 换行符为 x' ...
- scrapy入门实践1
Scrapy是一个为了爬取网站数据,提取结构性数据而编写的应用框架. 可以应用在包括数据挖掘,信息处理或存储历史数据等一系列的程序中. 这就是整个Scrapy的架构图了: 各部件职能: Scrapy ...
- 微信小程序 报错Setting data field "variableName" to undefined is invalid.
Setting data field "variableName" to undefined is invalid. 将数据字段“variableName”设置为未定义是无效的. ...
- 用TCP穿透NAT(TCP打洞)的实现
目录 TCP穿透原理 程序思路 声明 上代码 运行示例 1. TCP穿透原理: 我们假设在两个不同的局域网后面分别有2台客户机A和 B,AB所在的局域网都分别通过一个路由器接入互联网.互联网上有一台服 ...
- 终于解决了一个Win7 下 VS 编译的问题,困扰了我好几个月
用 Win7 一年多了,一直在这个环境下编程,其他都挺好,就是有个问题非常恶心,在VS下编译经常出现进程正在使用,无法覆盖的错误,这个问题我记得博问中以前也有其他人遇到过,也没有解决掉.此问题困扰了我 ...