#53353: 又又又是費式數列


Tino961009 (能AC,就別管怎麼AC)

學校 : 國立臺中第二高級中學
編號 : 288138
來源 : [111.82.100.143]
最後登入時間 :
2025-10-11 12:15:02

c 547 的進階版
沒想法的可以先去看
提示 : 可以用補給站分段在相乘

#include<bits/stdc++.h>
using namespace std;
int main(){
 
int n, m;
cin>>n>>m;
 
vector<int> method(n+1);
method[1]=method[2]=1;
method[3]=2;
 
for(int i=4; i<=n; i++){
method[i]=(method[i-1]+method[i-3])%1000000007;
}
 
int b=0, now;
long long ans=1;
for(int i=0; i<m; i++){
 
cin>>now;
ans*=method[now-b];
ans=ans%1000000007;
b=now;
 
}
 
ans*=method[n-b];
ans=ans%1000000007;
 
cout<<ans<<endl;
 
return 0;