1 solutions

  • -5
    @ 2023-12-25 14:03:58

    这题磨了我两个月

    我试过递归,

    也玩过递推,

    递归记忆化,

    递推最优化,

    最后输在了打表上。

    #include<iostream>
    using namespace std;
    int Pell[1000001]={1,2};
    int main(){
    	for(int i=2;i<1000001;i++)
    	Pell[i]=(2*Pell[i-1]+Pell[i-2])%32767;
    	int n;
    	cin>>n;
    	while(n--){
    		int k;
    		cin>>k;
    		cout<<Pell[k-1]<<"\n";
    	}
    }
    
    • 1

    Information

    ID
    675
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    6
    Tags
    # Submissions
    38
    Accepted
    12
    Uploaded By