261. Discrete Roots
time limit per test: 1
sec.
memory limit per test: 65536
KB
input: standard
output: standard
There are a lot of mysteries and legends around computer science. One of the stories tells us about three Russian hackers who know the secret of breaking down widely used cryptographic algorithm. The fact itself threatens security of economics of many countries. Until recent time nobody knew anything about these hackers but now federal security bureau knows their names (Roman, Sergey and Andrew) and they also know that their hack method somehow uses discrete roots finding algorithm. And of course nobody knows this algorithm. We suggest you to try to solve much simpler task.
Given two prime numbers P and K (2 <= P <= 10^9, 2 <= K <= 100000) and integer number A (0 <= A < P) you are to find all the roots of the equation x^K = A mod P.
Input
Integer numbers P, K, A.
Output
The first line of output should contain number of roots of the equation. On the second line all the roots should be listed in ascending order.
Note: all the roots should be in the range [0..P1].
Sample test(s)
Input
11 3 8
Output
1
2
Author:  Igor A. Kulkin

Resource:  Saratov SU Contest: Golden Fall 2004

Date:  October 2, 2004

Server time: 20171122 21:01:41  Online Contester Team © 2002  2016. All rights reserved. 

