题目地址:
http://acm.hdu.edu.cn/showproblem.php?pid=2045
有点小麻烦。。。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | // Author: Tanky Woo // HDOJ 2045 #include <iostream> #include <string.h> using namespace std; __int64 result[55]; int main() { result[1] = 3; result[2] = 6; result[3] = 6; for(int i=4; i<=50; ++i) result[i] = result[i-1]+2*result[i-2]; int num; while(scanf("%d", &num) != EOF) printf("%I64d\n", result[num]); return 0; } |
If you do’t write the thought of solving the problm ,instead writing the code,it is meanless