返回题解分享
讨论 / 题解分享/ 帖子详情

积木画(编程题) - 题解

本体要运用到数学知识,进行推理

#include<bits/stdc++.h>

using namespace std;

const int N=1e7+10,mod=1000000007;

int f[N];

int main(){

ios::sync_with_stdio(false),cout.tie(0),cin.tie(0);

f[1]=1;

f[2]=2;

f[3]=5;

int n;cin>>n;

for(int i=4;i<=n;i++)

{

	f[i]=(2*f[i-1]%mod+f[i-3]%mod)%mod;

}

cout<<f[n];

return 0;


}
0 回复 0 转发 0 喜欢 0 阅读
回复 (0)
默认 最新
暂无回复,快来抢沙发!