|
|
back to boardwhere is my error ....... i got WA Posted by GoGo 25 Mar 2002 20:28 #include <stdio.h> long n,m,y,x; void read_data() { FILE *f=stdin; fscanf(f,"%ld%ld%ld",&n,&m,&y); } long expon_modul(int a) { long c=0,d=1,i; for(i=15;!(n & (1 << i));i--); for(;i>=0;i--) { c*=2; d=(d*d)%m; if(n & (1 << i)) { c++; d=(d*a)%m; } } return(d); } void solve() { long i; if(!y)printf("0 "); for(i=1;i<m;i++) if(expon_modul(i)==y)printf("%ld ",i); } void main() { read_data(); solve(); } read the output specification again > #include <stdio.h> > > long n,m,y,x; > > void read_data() > { > FILE *f=stdin; > fscanf(f,"%ld%ld%ld",&n,&m,&y); > } > > long expon_modul(int a) > { > long c=0,d=1,i; > for(i=15;!(n & (1 << i));i--); > for(;i>=0;i--) > { > c*=2; > d=(d*d)%m; > if(n & (1 << i)) > { > c++; > d=(d*a)%m; > } > } > return(d); > } > > void solve() > { > long i; > if(!y)printf("0 "); > for(i=1;i<m;i++) > if(expon_modul(i)==y)printf("%ld ",i); > } > > void main() > { > read_data(); > solve(); > } |
|
|