chillurbrain

5. Степень

May 21st, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdio>
  3. using namespace std;
  4. bool check(int num, int pow, int div, int rem)
  5. {
  6.     int i,b;
  7.     b=1;
  8.     for(i=1; i<=pow; i++)
  9.     {
  10.         b = b * num;
  11.         b = b % div;
  12.     }
  13.     if(b==rem)
  14.         return true;
  15.     return false;
  16.    
  17. }
  18. int main()
  19. {
  20.     int n, m, z, i;
  21.     bool pr = false;
  22.     scanf("%d%d%d",&n,&m,&z);
  23.     for(i=0; i<m; i++)
  24.         if(check(i, n, m, z))
  25.         {
  26.             printf("%d ", i);
  27.             pr=true;
  28.         }
  29.     if(pr == false)
  30.         printf("-1");
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment