您的位置:首页 > 其它

杭电2070

2016-07-29 16:07 351 查看
/*此题主要注意数组类型注意内存主函数若用递归协会超时,因为for循环过大n平方所以用递推式学习动态规划后只需将动态转移方程写出来即可*/
#include<iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

__int64 a[100];

int main()
{
int fn1, fn2;
__int64 n;
while(scanf("%I64d", &n) != EOF && n != -1){

a[0] = 0;
a[1] = 1;
for(int i = 2; i <= n; i++){
a[i] = a[i - 1] + a[i - 2];//代码主要在这里 推出动态方程即可
}
cout << a
<< endl;
}
return 0;
}


*/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: