F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Alexandra and A*B Problem

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1047    Accepted Submission(s): 331


Problem 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
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-05-05 09:53:04, Gzip enabled