等边三角形
![在这里插入图片描述](https://img-blog.csdnimg.cn/direct/52d719c915184fdb8b20f8473ed2c780.png#pic_center)
代码
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, flag = 0, sum = 0, tag;
int length[20];
int group[3] = {0};
void dfs(int i, int index)
{
group[index] += length[i];
if (group[1] > tag || group[0] > tag || group[2] > tag)
{
group[index] -= length[i];
return;
}
if (group[0] == tag && group[1] == tag)
{
flag = 1;
return;
}
if (i + 1 < n)
{
if (!flag)
dfs(i + 1, 0);
if (!flag)
dfs(i + 1, 1);
if (!flag)
dfs(i + 1, 2);
}
group[index] -= length[i];
return;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n;
for (int i = 0; i < n; i++)
{
cin >> length[i];
sum += length[i];
}
tag = sum / 3;
if (sum % 3 == 0)
dfs(0, 0);
if (flag)
cout << "yes";
else
cout << "no";
return 0;
}