|
|
back to boardThis is my answer! Posted by train 21 Sep 2002 17:41 #include "stdio.h" main() { long n, m, y, x, i, temp, flag=0; scanf("%ld %ld %ld",&n,&m,&y); for (x=0; x<m; x++) { temp = x; for (i=2; i<=n; i++) { temp *= x; temp %= m; } if (temp==y) { if (flag>0) printf(" "); printf("%ld",x); flag++; } } if (flag==0) printf("-1"); printf("\n"); } Re: This is my answer! > #include "stdio.h" > > main() { > long n, m, y, x, i, temp, flag=0; > > scanf("%ld %ld %ld",&n,&m,&y); > for (x=0; x<m; x++) { > temp = x; > for (i=2; i<=n; i++) { > temp *= x; > temp %= m; > } > if (temp==y) { > if (flag>0) printf(" "); > printf("%ld",x); > flag++; > } > } > if (flag==0) printf("-1"); > printf("\n"); > > } |
|
|