using namespace std;
Int fib (int n) {
If (n==1) return 1;
If (n==2) return 1;
Return fib (n - 1) + fib (n - 2);
}
Int main ()
{
int n; Cin> n;
Cout
}
Code output time is too long, how should improve?
CodePudding user response:
Unsigned long long ffib (int n)
{
If (n & lt; 1) return 0;
If (n & lt; 3) return 1;
If (n & amp; 1) return - n/a=2, ffib ffib (n + 1) * (n + 1) + ffib * ffib (n) (n);
Return "n/a=2, ffib (n) * (ffib (n + 1) * 2 - ffib (n));
}
Can calculate to n=93 seconds, again big results will overflow the