|
|
back to boardwhy wa in test 1? Posted by bottles 20 Oct 2007 06:33 #include<iostream> #include<cstdio> using namespace std; int solve(int n,int k){ unsigned long long a[3]={0}; a[0]=1; a[1]=k-1; for(int i=2;i<=n;i++) a[i%3]=(k-1)*(a[(i-1)%3]+a[(i-2)%3]); printf("%I64u\n",a[n]); return 0; } int main() { int n,k; //while(1){ scanf("%d%d",&n,&k); solve(n,k); //} return 0; } |
|
|