http://acm.hdu.edu.cn/showproblem.php?pid=2085
这也是一个简单的的递推。
a[i][0] = 3*a[i-1][0]+2*a[i-1][1];
a[i][1] = a[i-1][0]+a[i-1][1];
#include <stdio.h> int main() { __int64 a[35][2]; int i,j,k; a[0][0] = 1; a[0][1] = 0; a[1][0] = 3; a[1][1] = 1; for (i = 2;i<=33;i++) { a[i][0] = 3*a[i-1][0]+2*a[i-1][1]; a[i][1] = a[i-1][0]+a[i-1][1]; } while (scanf("%d",&j)!=EOF&&j!=-1) printf("%I64d, %I64d\n",a[j][0],a[j][1]); return 0; }
原文地址:http://blog.csdn.net/jiangpengna/article/details/43700763