标签:
不容易系列之(3)—— LELE的RPG难题
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 15018 Accepted Submission(s): 5938
根据前面几项,推出从第四个开始,为a【i-1】+2*a【i-2】;注意数大于int型,所以用long long。
#include <stdio.h> int main() { long long n,x[55]={3,6,6},i; while(scanf("%lld",&n)!=EOF) { for(i=3;i<n;i++) x[i]=x[i-1]+2*x[i-2]; printf("%lld\n",x[n-1]); } return 0; }
标签:
原文地址:http://www.cnblogs.com/zhangfengnick/p/4423051.html