Advertisement
Saleh127

Untitled

May 5th, 2020
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. int main()
  5. {
  6. vector<ll>a;
  7. a.clear();
  8. ll n,m,y,i,j,k,l;
  9. cin>>n>>m>>y;
  10. for(i=0; i<m; i++)
  11. {
  12. int ans=i;
  13. for(k=1;k<n;k++)
  14. {
  15. ans*=i;
  16. ans%=m;
  17. }
  18. if(ans==y)
  19. {
  20. a.push_back(i);
  21. }
  22. }
  23. if(a.size()==0) printf("-1\n");
  24. else
  25. {
  26. for(j=0; j<a.size(); j++)
  27. {
  28. if(j!=a.size()-1) printf("%lld ",a[j]);
  29. else printf("%lld\n",a[j]);
  30. }
  31. }
  32. return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement