Advertisement
Asif_Anwar

Timus-1110. Power

Apr 8th, 2021
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.97 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. #define pb push_back
  5. #define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  6. #define F first
  7. #define S second
  8. typedef long long ll;
  9. typedef vector< int > vi;
  10. typedef vector< ll > V;
  11. typedef map<int, int > mp;
  12. #define debug cout << -1 << endl;
  13. #define REP(i, a, b) for(int i=a; i<b; i++)
  14. #define pop pop_back
  15. const ll MOD = 1000000007;
  16. const int maxN = 2001;
  17.  
  18. int dx[] = {-1, 0, 1, -1, 1, -1, 0, 1};
  19. int dy[] = {-1, -1, -1, 0, 0, 1, 1, 1};
  20.  
  21. void solve()
  22. {
  23.     ll n, m, y;
  24.     cin >> n >> m >> y;
  25.     //vi v;
  26.     int cnt = 0;
  27.     REP(i, 0, m) {
  28.         int mul = 1;
  29.         REP(j, 0, n) {
  30.             mul = ((mul%m) * (i%m))%m;
  31.         }
  32.         if(mul%m==y) {
  33.             cnt++;
  34.             cout << i << " ";
  35.         }
  36.     }
  37.     if(!cnt) cout << -1  << endl;
  38.     cout << endl;
  39. }
  40.  
  41. int main()
  42. {
  43.     FastIO;
  44.     //freopen("billboard.in","r",stdin);
  45.     //freopen("billboard.out","w",stdout);
  46.     int t;
  47.     t = 1;
  48.     //cin >> t;
  49.     while(t--){
  50.         solve();
  51.     }
  52.     return 0;
  53. }
  54.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement