#include <bits/stdc++.h>
using namespace std;
unsigned long long int f(unsigned long long int x){
if(x==0)return 1;
else if(x==1)return 3;
else return 2*f(x-1)+f(x-2);
}
int main()
{
unsigned long long int n;
cin>>n;
cout<<f(n)<<"\n";
return 0;
}
n=50跑不出來
#include <bits/stdc++.h>
using namespace std;
unsigned long long int f(unsigned long long int x){
if(x==0)return 1;
else if(x==1)return 3;
else return 2*f(x-1)+f(x-2);
}
int main()
{
unsigned long long int n;
cin>>n;
cout<<f(n)<<"\n";
return 0;
}
可以跑出來 但會TLE
#include <bits/stdc++.h>
using namespace std;
unsigned long long int f(unsigned long long int x){
if(x==0)return 1;
else if(x==1)return 3;
else return 2*f(x-1)+f(x-2);
}
int main()
{
unsigned long long int n;
cin>>n;
cout<<f(n)<<"\n";
return 0;
}
可以跑出來 但會TLE
沒事 解決了