0
点赞
收藏
分享

微信扫一扫

B. Lovely Palindromes 震惊!字符数组长度竟然可以无视?????!!!

扒皮狼 2022-06-29 阅读 47

time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
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?

Input
The only line of the input contains a single integer n (1 ≤ n ≤ 10100 000).

Output
Print the n-th even-length palindrome number.

Examples
inputCopy
1
outputCopy
11
inputCopy
10
outputCopy
1001
Note
The first 10 even-length palindrome numbers are 11, 22, 33, … , 88, 99 and 1001.
思路:这道题n的范围给的是10的100000次方,刚开始震惊了,提交竟然A了????
试了多种方法才发现字符数组可以无视长度啊。
直接模拟即可

///***Created by Xiang wang *** ACMÈÙҫ֮·***
//#include <bits/stdc++.h>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<queue>
#include<cmath>
#include<cctype>
#include<stack>
#include<map>
#include<string>
#include<cstdlib>
#define ll long long
const int INF = 0x3f3f3f3f;
const ll LIMIT = 4294967295LL;
const ll maxn = -1;
const ll minn = 10000000010;
using namespace std;
ll a[1000100], b[1000100];
char n[0];
int main() {
ll i, j;
ll maxn = -1;
ll minn = 10000000010;
while(cin >> n)
{
cout<<n;
for(i=strlen(n)-1;i>=0;i--)
cout<<n[i];
cout<<endl;
}
return 0;
}


举报

相关推荐

0 条评论