A30643|Pell数列-题解
2026-08-26 21:16:42
发布于:广东
1阅读
0回复
0点赞
解法:
1:
题目给出递推式:
可得代码:
#include<bits/stdc++.h>
using namespace std;
const int MOD= 32767;
int pell(int x){
if(x==1)return 1;
if(x==2)return 2;
return (2*pell(x-1))+pell(x-2)%MOD;
}
int main(){
int q;
cin>>q;
while(q--){
int n;
cin>>n;
cout<<pell(n)<<'\n';
}
}
这里空空如也







有帮助,赞一个