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

drunkpalindrome Batch , stdin/stdout

Registered Users Only

Please login to utilize this feature.

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

drunkpalindrome.html

Problem Description

Gug likes palindromes, so he built an AI to tell if a number is a palindrome. When given a number N, she will say "N is almost a palindrome. It is only X away from the nearest palindrome."

Help Gug's AI find X, the distance to the nearest palindrome

A palindrome is a number that reads the same backward as forward, for example, 1234321, 0 and 10001 are palindromes, but 1112, 100, and 123211 is not. Numbers with leading 0s like 010 are not allowed.

The distance between 2 numbers a and b is defined as |a-b|.

Input

The input will consist of one line, the number N as defined above.

Output

The output should contain one line with the integer X as defined above.

Limits

Subtask 1(1%): 0 < N < 10

Subtask 2(17%): 0 < N < 106

Subtask 3(29%): 0 < N < 1012

Subtask 4(53%): 0 < N < 1018

Subtask 5(0%): Sample

Sample Input 1

12

Sample Output 1

1

Explanation

12 is 1 away from 11, a palindrome.

Sample Input 2

19

Sample Output 2

3

Explanation

19 is 3 away from 22, a palindrome.

Tags

Ad Hoc

Subtasks and Limits

Subtask Score #TC Time Memory Scoring
1191s256MBMinimum
217121s256MBMinimum
329131s256MBMinimum
453131s256MBMinimum
5021s256MBMinimum

Judge Compile Command

g++-8 ans.cpp -o drunkpalindrome -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.