|
|
вернуться в форум1012 My Code Help Послано daiwb 18 июн 2003 09:20 #include <iostream> #include <iomanip> #include <cmath> using namespace std; long c(double n,double m){ long i; double result=1; for(i=(long)m+1;i<=(long)n;i++){ result*=(double)i/(double)(i-m); } return (long)result; } int main(void){ long num_zero,i; double k,n,sum=0; cin>>n>>k; num_zero=(long)n/2; for(i=0;i<=num_zero;i++){ sum+=pow(k-1,n-i)*c(n-i,i); } cout<<setiosflags(ios::fixed)<<setprecision(0)<<sum<<endl; return 0; } |
|
|