为何不过

hebaijun 2024-10-23 20:29:15 3

#include<bits/stdc++.h> using namespace std; int main(){ freopen("B.in","r",stdin); freopen("B.out","w",stdout); int n,k,a[100],b[100]={0},v; cin>>n>>k; for(int i=1;i<=k;i++){ cin>>v; b[v]=1; } if(b[1]==1&&b[2]==1){ cout<<0; return 0; }else if(b[1]==1&&b[2]==0){ a[1]=0; a[2]=1; }else if(b[1]==0&&b[2]==1){ a[1]=1; a[2]=0; }else{ a[1]=1; a[2]=2; } for(int i=3;i<=n;i++){ if(b[i]==1){ a[i]=0; }else a[i]=a[i-1]+a[i-2]; } cout<<a[n]; return 0; }

{{ vote && vote.total.up }}

共 1 条回复

root 站长

不开 long long ***