求救,帮我看看哪里有问题
查看原帖
求救,帮我看看哪里有问题
1109112
H_Accecpted楼主2024/10/12 01:21
#include<bits/stdc++.h>
using namespace std;
int f[1000010]={0,1,2,5,11},g[1000010]={0,0,1,2};
int n;
int F(int x);
int G(int x); 
int F(int x)
{

	if(f[x]<=4)
		return f[x];
	f[x]=(F(x-1)+F(x-2)+2*F(x-1));
}
int G(int x)
{
	if(g[x]<=3)
		return g[x];
	g[x]=F(x-2)+G(x-1);
}
int main()
{

	cin>>n;
	int s=F(n);
	cout<<s;
} 

求救,实在搞不懂到底出了什么问题,只要大于4总是输出4661312,找了半天还是没找着,我快崩溃了(QwQ)

2024/10/12 01:21
加载中...