p4994 终于结束的起点题目链接:终于结束的起点
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+10;
long long gh[N];
long long ans=1;
long long m;
long long fun(long long x)
{
if(gh[x]) return gh[x];
if(x==1||x==2)return gh[x]=1%m;
else return gh[x]=(fun(x-1)+fun(x-2))%m;
}
int main()
{
ios::sync_with_stdio(false);
cin>>m;
while(fun(ans)!=0||fun(ans+1)!=1)
{
ans++;
}
cout<<ans;
return 0;
}