大佬能不能帮我看看这段代码为什么会TLE,是pow的问题吗?
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL m, n = 1, f[700010];
LL fib(double n){
double sqrt5 = sqrt(5);
double phi = (1 + sqrt5) / 2;
double psi = (1 - sqrt5) / 2;
double result = (1 / sqrt5) * (pow(phi, n) - pow(psi, n));
return result;
}
int main(){
cin >> m;
while(true){
if(fib(n)%m == 0 && fib(n+1)%m ==1){
cout << n;
return 0;
}
else{
n++;
}
}
}