@[suyiheng](/space/show?uid=114149)
@[DaRK52](/space/show?uid=81922)
by shitbro @ 2018-11-04 13:19:31
~~RP不好吧(逃~~
by suyiheng @ 2018-11-04 13:22:33
A数组太小
打表证明需要开到21000000
by henry_y @ 2018-11-04 13:23:26
a[1]=a[2];
a[0]=a[1];这两句顺序换一下,你理一下逻辑就知道为什么错了@[larry2004](/space/show?uid=90972)
by DaRK52 @ 2018-11-04 13:26:43
```cpp
#include<string>
#include<cstdio>
#include<iostream>
using namespace std;
long long a[21000000];
int main()
{
/*freopen(" ","r",stdin);
freopen(" ","w",stdout);*/
int n;
cin>>n;
a[0]=0;
a[1]=1;
for(int i=2;i<=n*n;i++)
{
a[i]=(a[i-1]+a[i-2])%n;
if(a[i]==1&&a[i-1]==0)
{
cout<<i-1<<endl;
return 0;
}
}
/*fclose(stdin);
fclose(stdout);*/
return 0;
}
```
90分了
@[suyiheng](/space/show?uid=114149)
@[DaRK52](/space/show?uid=81922)
by shitbro @ 2018-11-04 13:27:23
把
a[1]=a[2];
a[0]=a[1];
换成
a[0]=a[1];
a[1]=a[2];
就好了,不然会a[0],a[1]都变成a[2]
by suyiheng @ 2018-11-04 13:27:36
@[henry_y](/space/show?uid=36526)
by shitbro @ 2018-11-04 13:27:36
谢谢
by shitbro @ 2018-11-04 13:28:03
@[larry2004](/space/show?uid=90972) emmm假如是90分的话建议把循环条件直接弄成一直进行而不是i<=n*n
by DaRK52 @ 2018-11-04 13:29:38
@[larry2004](/space/show?uid=90972)
不要循环到$n*n$啊...
$while(1)$就行了,找到答案就return 0
by henry_y @ 2018-11-04 13:37:10