HDU 5680 zxa and set水問題

2099 ワード

zxa and set
テーマ接続:
http://acm.hdu.edu.cn/showproblem.php?pid=4681
Description
zxa has a set A={a 1,a 2,⋯,a n}、which has n elemens and obviousy(2 n−1)non-empty subsets.
For each subset B={b 1,b 2,⋯,bm}(1≦m≦n)of A,which has m element,zxa defined its value as min(b 1,b 2,⋯,bm)
zxa is is interested to know、asuming ththat Sodd represents the sum of the values of the non-emptysets、in which set B is a subset of A and the number of elemens inininind、and Seven represents thethethethe emmthe of of thethethererererererererererererererererererererererereemens s s s s s s s s s s s s s s s s s s s s s s s s s s s s thererererererererererererererererererererererererererererererererereren,then what is the value of|Sodd−Seven|、can you help him?
Input
The first line contains an positive integer T,represents there are T test cases.
For each test case:
The first line contains an positive integer n,represents the number of the set A is n.
The second line contains n distinct positive integers、repersent the elements a 1、a 2、⋯、an.
The e e e e is a blank between each integer with no other extra space in one line.
1≦T≦100,1≦n≦30,1≦ai≦109
Output
For each test case,output in one line a non-negative integer,repersent the value of|Sodd−Seven|.
Sample Input
3 1 10 3 1 2 4 1 2 3 3 3 4
Sample Output
10 3 4
ベント
題意
zxaには集合\(A=\{au 1,au 2、\cdots、a n\)、\(n\)は集合\(A\)の元素個数を表していますが、この集合は明らかに\(((2^n-1)\)個の非空子集合があります。
各\(A\)に属するサブ集合\(B=\{b}の要素個数について、zxaがその価値を定義するのは\(min(b_1,b_2,bts 2,cdots)\)です。
zxaが好奇心を持っています。もし集合\(A\)の奇数の要素を含むすべての非空子集合の価値の和を表しているなら、\(S_{even}\の集合を表しています。
クイズ:
数学の方法でも、爆発的に検索しても、答えは最大値です。
直接輸出すればいいです。
コード
#include<bits/stdc++.h>
using namespace std;

void solve()
{
    int n;scanf("%d",&n);
    int ans=0,x;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&x);
        ans=max(ans,x);
    }
    printf("%d
",ans); } int main() { int t; scanf("%d",&t); while(t--)solve(); return 0; }