Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdio>
- using namespace std;
- bool check(int num, int pow, int div, int rem)
- {
- int i,b;
- b=1;
- for(i=1; i<=pow; i++)
- {
- b = b * num;
- b = b % div;
- }
- if(b==rem)
- return true;
- return false;
- }
- int main()
- {
- int n, m, z, i;
- bool pr = false;
- scanf("%d%d%d",&n,&m,&z);
- for(i=0; i<m; i++)
- if(check(i, n, m, z))
- {
- printf("%d ", i);
- pr=true;
- }
- if(pr == false)
- printf("-1");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment