编程语言
首页 > 编程语言> > 程序设计实习MOOC / 程序设计与算法(一)第6周测验(2019夏季)

程序设计实习MOOC / 程序设计与算法(一)第6周测验(2019夏季)

作者:互联网

001:Pell数列

#include <iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#pragma warning(disable:4996)
using namespace std;
unsigned int pell[1000010];
int a[100];
int main()
{
	//freopen("C:\\Users\\czh\\Desktop\\2.txt", "r", stdin);
	int n;
	cin >> n;
	for (int i = 0;i < n;i++)
		cin >> a[i];
	int Max = 0;
	for (int i = 0;i < n;i++)
		Max = Max < a[i] ? a[i] : Max;
	pell[1] = 1;
	pell[2] = 2;
	for (int i = 3;i <= Max;i++)
		pell[i] = (2 * pell[i - 1] + pell[i - 2]) % 32767;
	for (int i = 0;i < n;i++)
		cout << pell[a[i]] << '\n';
	return 0;
}

 

标签:MOOC,int,Max,++,cin,pell,2019,程序设计,include
来源: https://blog.csdn.net/qq_33941843/article/details/97417912