AMATH - Another Mathematical Problem
Given two numbers n (1<=n<10100) and k (1<=k<=100), you are to determine whether there exists a positive integer T which satisfies that for every positive integer a, na+T-na is divisible by 10k.
Input
Multiple test cases. Each test case contains two space-separated integers n and k. Input terminate by EOF.
The number of test cases will not more than 20.
Output
For each test case, you should output the smallest positive integer number T which satisfies the condition above, or -1 if it doesn't exist.
Example
Input: 32 2 Output: 4
Added by: | Fudan University Problem Setters |
Date: | 2007-07-01 |
Time limit: | 1s |
Source limit: | 2048B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: C99 ERL JS-RHINO |
Resource: | Folklore, description and standard program by Blue Mary |