solution
暴力枚举三个数字,看一下是不是满足“任意两数之和大于第3个数”就行了。
code
/* * @Author: wxyww * @Date: 2020-05-08 19:01:05 * @Last Modified time: 2020-05-08 19:02:36 */ #include<cstdio> #include<iostream> #include<cstdlib> #include<cmath> #include<ctime> #include<bitset> #include<cstring> #include<algorithm> #include<string> #include<queue> #include<vector> using namespace std; typedef long long ll; const int N = 110; ll read() { ll x=0,f=1;char c=getchar(); while(c<'0'||c>'9') { if(c=='-') f=-1; c=getchar(); } while(c>='0'&&c<='9') { x=x*10+c-'0'; c=getchar(); } return x*f; } int a[N]; int main() { int n = read(); for(int i = 1;i <= n;++i) { a[i] = read(); } for(int i = 1;i <= n;++i) { for(int j = i + 1;j <= n;++j) { for(int k = j + 1;k <= n;++k) { if(a[i] + a[j] > a[k] && a[i] + a[k] > a[j] && a[j] + a[k] > a[i]) { printf("%d %d %d\n",a[i],a[j],a[k]); return 0; } } } } puts("No solution"); return 0; }