Description
1tthinking In addition to the random algorithm, nothing else. But he can still ac a lot of questions, what does he use? He would choose a good random seed and then output the answer. Often he chooses a good seed that can have a probability of 99% ac problems.
He will choose a seed according to the following rules. First 1tthinking has its own favorite lucky number x. And then he'll find a number a so that (1)A is a is a multiple of x (2) a with a decimal representation that contains 0 to 9.
For example, if x = 1, then 9182736450 is a random seed that 1tthinking needs.
However, 1tthinking sometimes took a long time to find this number, he felt very disappointed. Now he has left the problem to you.
Input
Line 1th, an integer t (0≤ t ≤100), the number of lucky numbers.
2nd to T + 1 line: XI (0≤ XI ≤106), 1tthinking lucky number.
Output
1th to T: An integer yi (0≤ yi ≤1016) that satisfies the condition of the random seed. If not present, output-1.
Sample Input3
1
2
10
Sample Output9876543210
9876543210
9876543210
HINTSource
Acknowledgement dnc1994 provides SPJ program
Solution
Set $ A = 1234567890000000 + x$, then (a-a% x) must be a multiple of x. (Well, there seems to be a little detail ...)
1#include <bits/stdc++.h>2 using namespacestd;3 intMain ()4 {5 Long LongT, X, A;6CIN >>T;7 while(t--)8 {9CIN >>x;TenA = 1234567890000000LL +x; Onecout << (x a-a% x:-1) <<Endl; A } - return 0; -}
View Code
[BZOJ2296] [POJ Challenge] Random seed