Do You Know Your ABCs?C语言

Farmer John's cows have been holding a daily online gathering on the "mooZ" video meeting platform. For fun, they have invented a simple number game to play during the meeting to keep themselves entertained.
Elsie has three positive integers A, B, and C (A≤B≤C). These integers are supposed to be secret, so she will not directly reveal them to her sister Bessie. Instead, she gives Bessie seven (not necessarily distinct) integers in the range 1…10^9, claiming that they are A, B, C, A+B, B+C, C+A, and A+B+C in some order.

Given a list of these seven numbers, please help Bessie determine A, B, and C. It can be shown that the answer is unique.

输入

The only line of input consists of seven space-separated integers.

输出

Print A, B, and C separated by spaces.

样例输入 Copy
2 2 11 4 9 7 9
样例输出 Copy
2 2 7
提示

Test cases 2-3 satisfy C≤50.
Test cases 4-10 satisfy no additional constraints.

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a[12];
    int i,n=7;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    int a1,b,c;
    
    cout<<a[1]<<" "<<a[2]<<" "<<a[n]-a[1]-a[2];
    return 0;
 } 

  • 9
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值