Home > Back-end >  Bosses, please advice.
Bosses, please advice.

Time:10-09

20. Short-answer questions

===programming problem===

Given a n positive integers x (x=12345, for example), to the digital reversal it into a new positive integer y (i.e., y=54321), we will y x number of inversion for short, obviously, the x and y are mutually inversion, a number of the number of inversion algorithm and program implementation can reference materials P49 example 4,

Given a target number P, two Numbers x and y, meet:

(1) the number of x and y are mutually inversion,

(2) digits to the same x and y, is 3 digits, for example, the decimal number high 0 doesn't make any sense, not included in the figures; (example: x=1230, corresponding y=0321, y high doesn't make any sense to 0, y=321, x and y, it is not the reversal of the same digit number),

(3) and the value of x + y biggest and no more than P,

(4) the number of such a reversal of (a pair of x and y) there may be several of the most satisfy all requirements mentioned above x, the (understandable, and is no more than x + y P and largest, biggest x y is corresponding to meet the conditions of the smallest y, because x + y=y + x)



Two examples:

Example 1: P=127, x=92, then obtained the corresponding y=29, and 29=x + y=92 + 121, there can be no greater than the 121 meet the conditions of mutual reverse number by the way,

Example 2: P=32767, x=19331, then obtained the corresponding y=13391, and x + y=19331 + 13391=32722, there can be no greater than the 32722 meet the conditions of mutual reverse number by the way,



Please calculate P=Integer programming. MAX_VALUE; (P=2147483647) and meet the requirements of the question of maximum x,

Your answer:

(1) the value of x is given;

(2) to paste the debugging through the application in answer box,