No tags yet

No tag edit access

time limit per test: 1 sec.

memory limit per test: 65536 KB

memory limit per test: 65536 KB

input: standard

output: 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.

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.

Integer numbers P, K, A.

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..P-1].

Note: all the roots should be in the range [0..P-1].

Input

11 3 8

Output

1

2

2

Author: | Igor A. Kulkin |

Resource: | Saratov SU Contest: Golden Fall 2004 |

Date: | October 2, 2004 |

Codeforces (c) Copyright 2010-2020 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Sep/21/2020 00:31:16 (i2).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|