暴力计算fib的值发现正好为0,而下一个值为1时停止就能AC,最长还只有20ms,离谱!!!
#include <cstdio>
int main(){
int m,now,lst = 1,llst = 0;
scanf("%d",&m);
for (int i = 2;;i++){
now = (lst + llst) % m;
if (now == 1 && lst == 0){
printf("%d\n",i - 1);
return 0;
}
llst = lst;
lst = now;
}
return 0;
}
#undef __cplusplus