zoukankan      html  css  js  c++  java
  • cf688B-Lovely Palindromes

    http://codeforces.com/problemset/problem/688/B

    B. Lovely Palindromes
    time limit per test
    1 second
    memory limit per test
    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?

    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
    Input
    1
    Output
    11
    Input
    10
    Output
    1001
    Note

    The first 10 even-length palindrome numbers are 11, 22, 33, ... , 88, 99 and 1001.

    题意:找第n个偶数位数的对称数字。

    思路:逻辑分析题。只看数字的一半(因为是偶数位数),它的一半是n,则它就是第n个符合要求的数。

    代码:

     1 #include <iostream>
     2 #include <cstring>
     3 using namespace std;
     4 
     5 #define n 100005
     6 
     7 int main ()
     8 {
     9     char s[n];
    10     cin >> s;
    11     int len = strlen(s);
    12     for (int i = 0; i < len; i++)
    13     {
    14         cout << s[i];
    15     }
    16     for (int i = len - 1; i >= 0; i--)
    17     {
    18         cout << s[i];
    19     }
    20     cout << endl;
    21     return 0;
    22 }
  • 相关阅读:
    循环选择判断文件类型
    SpringBoot+MyBatis+Mysql+Durid实现动态多数据源
    Spring 常用注解
    Spring IOC容器中那些鲜为人知的细节
    java8 Stream对List<Map>的分组合并操作
    Java8的CompletableFuture 使用详解
    Spring MVC源码分析
    Spring AOP源码分析
    Spring中AOP必须明白的几个概念
    UriComponentsBuilder和UriComponents url编码
  • 原文地址:https://www.cnblogs.com/jiu0821/p/5642556.html
Copyright © 2011-2022 走看看