By Ricardo Martins, IFSULDEMINAS Brazil
A palindrome is a word , phrase or any other sequence of units (like a chain of DNA; Restriction enzyme ) that has the property of being able to be read either from right to left and from left to right. Capicua or palindrome number is a number (or set of numbers ) integers whose reverse is himself. This problem want you to analyze a real number and verify that the lowest value that should be added to this so that it becomes a real palindrome without specific name so far. For example , if the number is 101.099 , to add to 0,002 , we get the real palindrome 101.101 . Another example would be the number 13.31 , which is already a real palindrome and must add 0 so that it stays that way. A final example is the number 100.9 , which should add 0.1 so that the sum becomes 101 .
Write a program that , given a real number , check the lower value to be added so that it becomes a real palindrome.
There will be several test cases . The first number being read C is an integer representing the number of test cases. Each test case has a real number R ( 0 ≤ R ≤ 999,999.999999 ) . Recalling that the entry will have a maximum of 6 decimal places, and the decimal separator is the point instead of comma.
For each test case output the expected value with the amount of required homes.
Input Sample | Output Sample |
3 101.099 13.31 100.9 |
0.002 0 0.1 |