1690 - A Simple Number Problem
Time Limit : 5 Second
Memory Limit : 512 MB
Submission: 30
Solved: 3
- Description
Mathematics knowledge is vital in Artificial Intelligence Area, Minieye wants to employ those who are good at Mathematics such as ACMers. Here is a problem related to mathematics Given 2n digits from 1 to 9, your task is to compose two integers A, B of length n, to minimize the value of |A+B-10n|. In this situation, leading zeros is legal.
- Input
There are several cases, first is the number of cases T. (T = 100000).
For each case, there is only one line contains a string of 2n digits.(n<=18)
- Output
For each case, output the minimum value in a line.
- sample input
-
3 9820 192747 000001
- sample output
-
0 7 900
- hint
Explanation for the samples:
|98 + 02 - 100| = 0
|274 + 719 - 1000| = 7
|100 + 000 - 1000| = 900
- source
- YY