Posted on 2008-04-08 15:52
superman 阅读(297)
评论(0) 编辑 收藏 引用 所属分类:
URAL
1 /* Accepted 0.001 196 KB */
2 #include <iostream>
3
4 using namespace std;
5
6 int main()
7 {
8 int n, k;
9 unsigned long long cnt[20][2] = {0};
10
11 cin >> n >> k;
12 cnt[1][1] = k - 1;
13 for(int i = 2; i <= n; i++)
14 {
15 cnt[i][0] = cnt[i - 1][1];
16 cnt[i][1] = (cnt[i - 1][0] + cnt[i - 1][1]) * (k - 1);
17 }
18 cout << cnt[n][0] + cnt[n][1] << endl;
19
20 return 0;
21 }
22