提示: 欢迎访问OurACM平台。
Problem 1652 Oaiei's game II

Accept: 47    Submit: 123
Time Limit: 1000 mSec    Memory Limit : 32768 KB

Problem Description

Oaiei is very interesting in symmetry number, and the following game that is he often playing.
Give you three integers: p, a, b. We hope you can get a p-base number X=x(n)x(n-1)...x(2)x(1)a, such that X*b=ax(n)x(n-1)…x(2)x(1).
For example: when p=2, X=01, b=2, then X*b=10 there a = 1 and x (1) =0.

Input

There are multiple test cases. For each test case, the first line are three integers P, a, b (1 <= P, a, b <= 1000, a < P).

Output

If you can’t find this X, please output “-1”; otherwise output the value of X. Separate each digit by a blank.

Sample Input

2 1 2

Sample Output

0 1

Source

FZU 2008 Summer Training III--Number Theory

Submit  Back  Status  Discuss