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 ...
随机推荐
- web 程序中的编码
比如字符串 <script type="text/javascript">alert('跨站攻击鸟')</script> 1.html encode ...
- substr 方法
substr 方法 返回一个从指定位置开始,并具有指定长度的子字符串. 参数 start 必选.所需的子字符串的起始位置.字符串中第一个字符的索引为 0. length 可选项.返回的子字符串中包含的 ...
- EDID真实数据块,请参考标准文档仔细核对
数据格式的详细说明:http://en.wikipedia.org/wiki/Extended_display_identification_data 下面是一个例子:
- Python学习之路day4-函数高级特性、装饰器
一.预备知识 学习装饰器需理解以下预备知识: 函数即变量 函数本质上也是一种变量,函数名即变量名,函数体就变量对应的值:函数体可以作为值赋给其他变量(函数),也可以通过函数名来直接调用函数.调用符号即 ...
- 初学者的Node.js学习历程
废话篇: 对于我这个新手的不能再白菜的人来说,nodejs的大名都有耳闻,所以说他是一项不可不克服的技能也是可以说的.但是之前没有搞清楚的情况之下胡乱的猜测,是的我对node.js没有一个具体的概念的 ...
- mac外接键盘修饰键设置
command 和 control 互换,option保持不变即可,差不多可以做到类似windows快捷键的使用习惯.
- Unity3D研究院之Assetbundle的实战(六十三)
http://www.xuanyusong.com/archives/2405 上一篇文章中我们相惜讨论了Assetbundle的原理,如果对原理还不太了解的朋友可以看这一篇文章:Unity3D研究院 ...
- MyBatis嵌套查询column传多个参数描述
代码如下,红色部分为关键代码. 注意parameterType要为java.util.HashMap <resultMap id="baseResultMap" type=& ...
- Linux网络编程——tcp并发服务器(poll实现)
想详细彻底地了解poll或看懂下面的代码请参考<Linux网络编程——I/O复用之poll函数> 代码: #include <string.h> #include <st ...
- MSDN 学习网站
-MSDN中文网站http://msdn.microsoft.com/zh-cn/-MSDN Webcast 中文网络广播http://msdn.microsoft.com/zh-cn/dd79616 ...