1020 : The Funny Number
时间限制Time Limit
1
秒Sec
内存限制Memory Limit
128
兆MB
提交次数Submitted
1
次Times
通过次数Solved
1
次Times
标准评测Standard Judge
题目描述Description
Add a specific digit p before and after a decimal positive integer k to get a new number. If the new number obtained is divisible by w, we call k a funny number.
Given p and w, could you get the smallest k?
For example: we set p=1 and w=9. The samllest k is 7, since add 1 before and after 7 we could get 171, which is divisible by 9. But numbers 1 ~ 6 (i.e. 111, 121, ... 161) could not.
输入格式Input
Each line contains two integer numbers p and w.
1 <= p <= 9 and 1 <= w <= 1000.
输出格式Output
For each case output oneline, The smallest funny number k in range [1, 10000].
If there’s no qualified k in range [1, 10000], output -1 instead.
样例Sample
出题Author
CSGrandeur