题目:https://www.51nod.com/onlineJudge/questionCode.html#!problemId=1090
思路:确定前两个,第三个就确定了。
#include<cstdio>
#include<queue>
#include<iostream>
#include<vector>
#include<map>
#include<cstring>
#include<string>
#include<set>
#include<stack>
#include<algorithm>
#define cle(a) memset(a,0,sizeof(a))
#define inf(a) memset(a,ox3f,sizeof(a))
#define ll long long
#define Rep(i,a,n) for(int i=a;i<=n;i++)
using namespace std;
const int INF = ( 2e9 ) + 2;
const int maxn = 1e3+10;
ll a[maxn];
map<ll,int> mp;
int main()
{
int n;
scanf("%d",&n);
for(int i=0;i<n;i++)
{
scanf("%lld",&a[i]);
mp[a[i]]++;
}
sort(a,a+n);
int flag=0;
for(int i=0;i<n;i++)
{
for(int j=i+1;j<n;j++)
{
int c=-(a[i]+a[j]);
if(c>a[j]&&mp[c])// 规定一个顺序
{
printf("%d %d %d\n",a[i],a[j],c);
flag=1;
}
}
}
if(flag==0)
printf("No Solution\n");
}