Alexandra and A*B Problem

Time Limit: 1000ms
Memory Limit: 32768KB
This problem will be judged on HDU. Original ID: 5109
64-bit integer IO format: %I64d      Java class name: Main

Description

Alexandra has a little brother. He is new to programming. One day he is solving the following problem: Given two positive integers A and B, output A*B.
This problem is even easier than the last one. Alexandra can't wait to give him another task: Given a positive integer A and a string S(S only contains numbers.), find the minimum positive integer B, such that S is a substring of T, where T is the decimal notation of A*B.
See the sample for better understanding.
Note: S can contain leading zeros, but T can't.

Input

There are multiple test cases (no more than 500). Each case contains a positive integer A and a string S.
$A \leq 10,000, 1 \leq |S| \leq 8$.

Output

For each case, output the required B. It is guaranteed that such B always exists.
To C++ programmers: if you want to output 64-bit integers, please use "%I64d" specifier or cout.

Sample Input

6 8
96 19
2 0086
1 1

Sample Output

3
2
5043
1

Source

Language: 
Theme: 
Share Code? 

Powered by NB231 | Current Style: .