E - Pairs (law of thought)

Title: E - Pairs
Here Insert Picture Description
Here Insert Picture Description
title meaning: T given set of data, the number of each group 10, 10 which is the number of x1, x2, x3, x4, x5 twenty-two obtained by adding small to each output of this earth number five.
Thinking: 10 which give the number of small to large order, sum of the number 10 and can be found to find the law, x3 = sum / 4, x3 as a breakthrough discovery rule.

AC Code

#include <bits/stdc++.h>

using namespace std;
long long a[20],b[10];
int main()
{
    int n;
    cin>>n;
    for(int k=1; k<=n; k++)
    {
        int sum=0;
        for(int i=1; i<=10; i++)
        {
            cin>>a[i];
            sum+=a[i];
        }
        sort(a+1,a+11);
        b[3]=sum/4-a[1]-a[10];
        b[1]=a[2]-b[3];
        b[2]=a[1]-b[1];
        b[5]=a[9]-b[3];
        b[4]=a[10]-b[5];
        printf("Case %d: ",k);
        for(int i=1; i<5; i++)
        cout<<b[i]<<" ";
        cout<<b[5]<<endl;
    }
    return 0;
}
Published 90 original articles · won praise 18 · views 3340

Guess you like

Origin blog.csdn.net/sherry_zhen/article/details/104283369
law