#include<bits/stdc++.h>
using namespace std;
int bigmod(int a, int b, int n)
{
if(b == 0)
return 1;
int x = bigmod(a, b/2, n);
x = (x*x)%n;
if(b%2 == 1)
x = (x*a)%n;
return x;
}
int main()
{
int n, m, y, i;
cin >> n >> m >> y;
set<int>s;
for(i=1;i<=m;i++)
{
int x = bigmod(i, n, m);
if(x == y)
s.insert(i);
}
if(s.size() == 0)
cout << -1 << "\n";
else
{
for(auto p = s.begin(); p != s.end(); p++)
cout << *p << " ";
cout << "\n";
}
return 0;
}
using namespace std;
int bigmod(int a, int b, int n)
{
if(b == 0)
return 1;
int x = bigmod(a, b/2, n);
x = (x*x)%n;
if(b%2 == 1)
x = (x*a)%n;
return x;
}
int main()
{
int n, m, y, i;
cin >> n >> m >> y;
set<int>s;
for(i=1;i<=m;i++)
{
int x = bigmod(i, n, m);
if(x == y)
s.insert(i);
}
if(s.size() == 0)
cout << -1 << "\n";
else
{
for(auto p = s.begin(); p != s.end(); p++)
cout << *p << " ";
cout << "\n";
}
return 0;
}
Comments
Post a Comment