22810_Palindrometer

2022-5-16 18:23| 发布者: Hocassian| 查看: 34| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-5-89506978488200-Problem List-采集的数据-后羿采集器.html

Pro.ID

22810

Title

Palindrometer

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=22810

AC

25

Submit

36

Ratio

69.44%

时间&空间限制

  • Time Limit: 1000/500 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    While driving the other day, John looked down at his odometer, and it read 100000. John was pretty excited about that. But, just one mile further, the odometer read 100001, and John was REALLY excited! You see, John loves palindromes — things that read the same way forwards and backwards. So, given any odometer reading, what is the least number of miles John must drive before the odometer reading is a palindrome? For John, every odometer digit counts. If the odometer reading was 000121, he wouldn't consider that a palindrome.

    输入

    There will be several test cases in the data file, each consisting of an odometer reading on its own line. Each odometer reading will be from 2 to 9 digits long. The odometer in question has the number of digits given in the input -- so, if the input is 00456, the odometer has 5 digits. There will be no spaces in the input, and no blank lines between input sets.

    The input data will end with a line with a single 0.

    输出

    Description

    While driving the other day, John looked down at his odometer, and it read 100000. John was pretty excited about that. But, just one mile further, the odometer read 100001, and John was REALLY excited! You see, John loves palindromes — things that read the same way forwards and backwards. So, given any odometer reading, what is the least number of miles John must drive before the odometer reading is a palindrome? For John, every odometer digit counts. If the odometer reading was 000121, he wouldn't consider that a palindrome.

    Input

    There will be several test cases in the data file, each consisting of an odometer reading on its own line. Each odometer reading will be from 2 to 9 digits long. The odometer in question has the number of digits given in the input -- so, if the input is 00456, the odometer has 5 digits. There will be no spaces in the input, and no blank lines between input sets.

    The input data will end with a line with a single 0.

    Output

    For each test case, output the minimum number of miles John must drive before the odometer reading is a palindrome. This may be 0 if the number is already a palindrome. Output each integer on its own line.

    Sample Input

    100000
    100001
    000121
    00456
    0

    Sample Output

    1
    0
    979
    44

    Source

    样例输入

    100000
    100001
    000121
    00456
    0

    样例输出

    1
    0
    979
    44

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部