|
|
вернуться в форумWhy my program can not be accepted?? Послано Danli 20 май 2009 11:16 #include<iostream.h> #include<math.h> int ji(int n); int main() { int k,n,m,c,a; int d=0; cin>>n>>k; if((k>=2&&k<=10)&&n>=2&&(n+k)<=18) { m=0; if(n%2==1) while(m<(n+1)/2) { c=ji(n-m); a=ji(m); d=d+int(pow(k-1,n-m-1)*c/a/ji(n-m-m)); m++; } else while(m<=(n+1)/2) { c=ji(n-m); a=ji(m); d=d+int(pow(k-1,n-m-1)*c/a/ji(n-m-m)); m++; } cout<<(k-1)*d<<endl; } return 0; } int ji(int n) { if(n==0) return 1; else return n*ji(n-1); } |
|
|