|
|
back to boardAC algo - f[i]=(k-1)*(f[i-1]+f[i-2]) Posted by MSDN 26 Jan 2008 17:04 #include <stdio.h> typedef unsigned long int INT; void main() { INT N,K,i; scanf("%lu%lu",&N,&K); INT *F=new INT[N]; F[0]=K-1; F[1]=K*F[0]; for(i=2;i<N;i++) F[i]=(K-1)*(F[i-1]+F[i-2]); printf("%lu",F[N-1]); } |
|
|