oj mrJudge
Toggle navigation
  • Login
    • Forget Password
      Login
User Image

Hello, Stranger

Guest
  • Analysis Mode
  • Problems
    • All Problems
    • Latest Problems
  • Join Us Now
  • Registration
  • Contact Us
  • Infomation
  • About
    • Terms of Use
    • Technical Specifications
    • Credits

palindromicnumber Batch , stdin/stdout

Registered Users Only

Please login to utilize this feature.

Do note that this website only supports submissions in C++.

palindromicnumber.html

Problem Description

A palindrome is defined as a string that reads the same forward and backward. For example, RAR is a palindrome while SAM and PEANUT is not. Any single character string is a palindrome.

A palindromic number is a number that is a palindrome. Hence, it is a number that reads the same forward or backwards. For instance, 2, 3, 11, 22, 131, 1991 are palindromic numbers.

Rar the Cat is interested in the N-smallest palindromic number and wants you to find out what is it.

Input

The first line of input will contain one integer, N.

Output

The output should contain one integer, the N-smallest palindromic number.

Limits

Subtask 1 (24%): 1 ≤ N < 2000. In addition, the answer is guaranteed to be lower than 106

Subtask 2 (27%): 1 ≤ N ≤ 106.

Subtask 3 (33%): 1 ≤ N ≤ 109.

Subtask 4 (16%): 1 ≤ N ≤ 1018.

Subtask 5 (0%): Sample Testcases

Sample Testcase 1

Input

3

Output

2

Explanation

The first three palindromic numbers are 0, 1 and 2.

Sample Testcase 2

Input

12

Output

22

Explanation

The first 12 palindromic numbers are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 22.

Tags

Math

Subtasks and Limits

Subtask Score #TC Time Memory Scoring
124230.5s256MBMinimum
227550.5s256MBMinimum
333890.5s256MBMinimum
4161570.5s256MBMinimum
5020.5s256MBMinimum

Judge Compile Command

g++-8 ans.cpp -o palindromicnumber -Wall -Wshadow -static -O2 -lm -m64 -s -w -std=gnu++17 -fmax-errors=512

Accepted Submissions

subIDUserTimeMax Time

Past Submissions

subIDUserTimeScore
mrJudge 09.05.20
Copyright © 2020 mrJudge. All rights reserved.