Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
3708 | 孙浚轩 | PELL数列 | C++ | Accepted | 71 MS | 264 KB | 369 | 2024-06-23 15:00:34 |
#include<iostream> using namespace std; int pell(int k){ if(k==1) return 1; else if(k==2) return 2; else{ int a=1,b=2,c; for(int i=0;i<k-2;i++){ c=(2*b+a)%32767; a=b; b=c; } return b; } } int main(){ int n; cin>>n; while(n--){ int k; cin>>k; cout<<pell(k)<<endl; } return 0; }