http://acm.hdu.edu.cn/showproblem#include<stdio.h>
#include<string.h>
int main()
{
_int64 a[41][2]={{0,1},{1,2}};
int i;
for( i = 2;i < 41;i ++){
a[i][0]=a[i-1][1];
a[i][1]=2*(a[i-1][0]+a[i-1][1]);
}
while(scanf("%d",&i)!=EOF)
{
printf("%I64d\n",a[i][0]+a[i][1] );
}
//system("pause");
}
.php?pid=2047
本文提供了一段使用 C 语言解决 HDU 2047 编程题目的代码示例。该算法通过动态规划计算特定数列,并能够根据输入返回相应的数列值之和。
380

被折叠的 条评论
为什么被折叠?



