题目链接:
Time Limit: 2000/1000 MS (Java/Others)
Memory Limit: 65536/65536 K (Java/Others)
For each subset B={b1,b2,⋯,bm}(1≤m≤n) of A, which has m elements, zxa defined its value as min(b1,b2,⋯,bm).
zxa is interested to know, assuming that Sodd represents the sum of the values of the non-empty sets, in which each set B is a subset of A and the number of elements in B is odd, and Seven represents the sum of the values of the non-empty sets, in which each set B is a subset of A and the number of elements in B is even, then what is the value of |Sodd−Seven|, can you help him?
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 a1,a2,⋯,an.
There is a blank between each integer with no other extra space in one line.
1≤T≤100,1≤n≤30,1≤ai≤10^9
//#include <bits/stdc++.h> #include <iostream> #include <queue> #include <cmath> #include <map> #include <cstring> #include <algorithm> #include <cstdio> using namespace std; #define Riep(n) for(int i=1;i<=n;i++) #define Riop(n) for(int i=0;i<n;i++) #define Rjep(n) for(int j=1;j<=n;j++) #define Rjop(n) for(int j=0;j<n;j++) #define mst(ss,b) memset(ss,b,sizeof(ss)); typedef long long LL; const LL mod=1e9+7; const double PI=acos(-1.0); const int inf=0x3f3f3f3f; const int N=1e5+25; int n,a[40]; int main() { int t; scanf("%d",&t); while(t--) { scanf("%d",&n); Riep(n)scanf("%d",&a[i]); sort(a+1,a+n+1); printf("%d\n",a[n]); } return 0; }