数据过水(请求加强数据) or 请求降橙
查看原帖
数据过水(请求加强数据) or 请求降橙
1074084
asd890123楼主2024/6/18 20:24

暴力计算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
2024/6/18 20:24
加载中...