|
|
вернуться в форумi compared my program with others.. whats wrong in my program Послано Nandhu 12 янв 2006 13:41 #include <stdio.h> #include<math.h> int main() { double n,m; short int y; int i; char flag='N'; scanf("%lf%lf%d",&n,&m,&y); for (i=1;i<m-1;i++) { if( (((int)(pow((double)i,n) )) % (int)m) == y) { printf("%d ",i); flag='Y'; } }
if(flag=='N') printf("-1"); return(0); } Re: i compared my program with others.. whats wrong in my program Послано wwwwww 13 янв 2006 11:28 pow(i,n) is a very big number (about 999^999) So pow(i, n) don't fit into int type. Try to write yourself Pow() function which will calculate not i^n but (i^n)%m And do it in integer numbers! You don't need double in this problem. Re: i compared my program with others.. whats wrong in my program Послано Nandhu 1 фев 2006 12:03 Thank you.... now its working.. |
|
|