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 ...
随机推荐
- 卸载全部appx应用(包括应用商店)
在PowerShell中粘贴: Get-AppXPackage | Remove-AppxPackage
- spring boot + thymeleaf 报错 org.thymeleaf.exceptions.TemplateInputException
org.thymeleaf.exceptions.TemplateInputException: Error resolving template "admin/verifyPassword ...
- python sort() sorted() 与argsort()函数的区别
1.python的内建排序函数有 sort.sorted两个 sort函数只定义在list中,sorted函数对于所有的可迭代序列都可以定义. for example: ls = list([5, 2 ...
- Django-进阶
分页 Django的分页器(paginator) view from django.shortcuts import render,HttpResponse # Create your views h ...
- Git_学习_09_Commit message 和 Change log 编写指南
一.前言 二.Commit message编写 1.规范 2.用空行分开主题和正文 提交时只执行 git commit,这时就会跳出文本编辑器,让你写多行. git commit 主题和正文分开 每次 ...
- commons-dbcp连接池的使用
数据库连接池 池参数(所有池参数都有默认值): 初始大小: 最小空闲连接数: 增量:一次创建的最小单位(5个) 最大空闲连接数:12个 最大连接数:20个 最大的等待时间:1000毫秒 四大连接参数: ...
- New Concept English three (47)
Pollution is the price we pay for an overpopulated, over industrialized planet. When you come to thi ...
- NET Core 2.0利用MassTransit集成RabbitMQ
NET Core 2.0利用MassTransit集成RabbitMQ https://www.cnblogs.com/Andre/p/9579764.html 在ASP.NET Core上利用Mas ...
- qduoj su003 数组合并
描述 现在呢有两个整形数组,a[n]和b[m],而且已经知道这两个数组都是非降序数组.现在呢就有一个工作需要你来完成啦.对于a中的每个元素a[i]在b中寻找<=a[i] 的元素个数,个数记为x[ ...
- uptime命令查看系统启动时间和运行时间、查看linux系统负载
1.uptime命令输出:16:11:40 up 59 days, 4:21, 2 users, load average: 0.00, 0.01, 0.00 2.查看/proc/uptime文件计算 ...