|
|
вернуться в форумWhy my program give WA ? this is my C prog . i don know why this prog give WA ? anyone how know it please mail me at : SSF_DIGI@HOTMAIL.COM thanks SABI #include <stdio.h> int n,k,z,lb,a[360],b[360]; void jam() { int temp[360]; int i; for (i=0;i<=lb;i++) temp[i] = b[i]; for (i=0;i<=lb;i++) { b[i] = a[i] + b[i]; if (b[i] > 9) { b[i] = b[i] - 10; b[i+1] = b[i+1] + 1; } } for (i=0;i<=lb;i++) a[i] = temp[i]; if (b[lb+1] > 0) lb++; } void zarb() { int j; for (j = 0 ;j <= lb ; j ++) { b[j] = b[j] * (k-1); if (b[j] > 9) { b[j] = b[j]/10; b[j+1] = b[j+1] + b[j]%10; } } if (b[lb+1] > 0) lb++; } void main(void) { scanf ("%d\n%d",&n,&k); a[0] = 0; b[0] = k; lb = 0; if (b[0] = 10) { b[0] = 0; b[1] = 1; lb = 1; } for (z=1;z<n-1;z++) { jam(); zarb(); } for (z=0;z<=lb;z++) { b[z] = b[z] * (k-1); if (b[z] > 9) { b[z+1] = b[z]/10; b[z] = b[z]%10; } } if (b[lb+1] > 0) lb++; for (z=lb;z>=0;z--) printf ("%d",b[z]); } |
|
|