wa in test 6 . help. thanks in advance
wa in test 6 . help. thanks in advance.
code:
#include <stdio.h>
#include <math.h>
int fun(int x,int n,int m,int y)
{
int i=1,mod=1;
while(n){
if(n%2)
mod=(mod*(int)pow(x,i))%m;
i*=2;
n/=2;
}
if(mod==y)
return 1;
else
return 0;
}
int main(void)
{
int n,m,y,x,c=0;
scanf(" %d%d%d",&n,&m,&y);
for(x=0;x<m;++x){
if(fun(x,n,m,y)){
printf("%d ",x);
++c;
}
}
if(c==0)
printf("-1\n");
else
putchar('\n');
return 0;
}