Time Exceeded
/in/foo.cc: In function 'int main()': /in/foo.cc:15:15: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'll* {aka long long int*}' [-Wformat=] scanf("%d",&n); ^
代码
#include<iostream>
#include<cstdio>
using namespace std;
typedef long long ll;
const int md=1e9+7;
ll f[4];
ll n;
void solve(){
f[1]=1,f[2]=1;
for(int i=3; i<=n+1; i++)
f[i%3] = (f[(i-1)%3] % md + f[(i-2)%3] %md) %md;
printf("%lld",f[(n+1)%3]);
}
int main(){
scanf("%d",&n);
solve();
return 0;
}