Power

http://acm.timus.ru/problem.aspx?space=1&num=1110

Time Limit: 0.5 second

Memory Limit: 1 000 KB

You are given the whole numbers N, M and Y. Write a program that will find all whole numbers X in the interval [0, M-1] such that X^N mod M = Y.

1. Input

The input contains a single line with N, M and Y (0<N<999, 1<M<999, 0<Y<99) separated with one space. Output

Output all numbers X separated with space on one line. The numbers must be written in ascending order. If no such numbers exist then output -1.

2. Sample Input

2 6 4

3. Sample Output

2 4

Problem Source: Bulgarian National Olimpiad Day #1


timus1110 (2008-02-23 15:34:10由localhost编辑)

ch3n2k.com | Copyright (c) 2004-2020 czk.