不要管标题,我这是求助帖。。。主要是因为没人看
我的代码哪里写的不规范,cf输出和本地不一样,求助大佬
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 505;
int n;
int a[N], b[N];
int res = -1;
bool st[N];
int ck()
{
int len;
for (int i = 3; i <= n + 1; i ++ )
if (b[i] != b[i - 1] + b[i - 2])
{
len = i - 1;
break;
}
return len;
}
void dfs(int u)
{
if (u == n + 1)
{
res = max(res, ck());
return;
}
for (int i = 1; i <= n; i ++ )
if (!st[i])
{
b[u] = a[i];
st[i] = 1;
dfs(u + 1);
st[i] = 0;
}
}
int main()
{
// freopen("fibonacci.in", "r", stdin);
// freopen("fibonacci.out", "w", stdout);
scanf("%d", &n);
if (n < 2)
{
printf("0\n");
return 0;
}
if (n == 2)
{
printf("2\n");
return 0;
}
for (int i = 1; i <= n; i ++ ) scanf("%d", &a[i]);
sort(a + 1, a + n + 1);
dfs(1);
printf("%d\n", res);
return 0;
}