#define graphinsertcheck(a, b) cout << "inserted: " << a << " to " << b << "\n"
#define graphinsertweightcheck(a, b, c) cout << "inserted: " << a << " to " << b << " weight: " << c << "\n"
typedeflonglong ll;
typedef vector<vector<ll>> vvll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
ll t, n, s;
const ll INF =1e9+7;
int main(){
cin>> t;
loopi(t){
cin>> n;
vll set(n);
loopj(n)cin>> set[j];
sort(set.begin(), set.end());// sort in ascending order
ll sum =0;
for(int j =1; j < n; j++) sum += set[j]*((1LL << j)-1);// sum contributions of 2nd biggest -> largest 1LL << i is the number of times its the largest in subset
loopj(n-1) sum -= set[j]*((1LL <<(n - j -1))-1);// subtract from smallest to 2nd biggest 1LL << n - i - 1 is # of times its the smallest in subset
Set Difference Add problem to Todo list
Problem code: SETDIFF
SUBMITMY SUBMISSIONSALL SUBMISSIONS
Read problems statements in Mandarin Chinese and Russian.
Churu is working as a data scientist in Coderpur. He works on a lot of data on the daily basis. One day, he found an interesting problem, which was very easy to solve for small data but was getting more complex with increasing number of data points. So, Churu needs your help in solving this problem.
Given a set S of N non-negative integers (Some integers might occur more than once in the set), find out the value of SETDIFF(S).
Mountain View
Where max(s) represents the maximum value in set s whereas min(s) represents the minimum value in the set s.
As value of SETDIFF(S) can be very large, print it modulo (109 + 7) .
Input
First line of input contains an integer T denoting number of test cases.
For each test case, first line will contain an integer N denoting number of elements in set S.
Next line contains N space separated integers denoting the set S.
Output
For each test case, print a single integer representing the answer of that test case.
Note
Two subsets will be called different if there exists an index i such that S[i] is occurs in one of the subset and not in another.
Constraints
Subtask #1: 20 points
1 ≤ T ≤ 5, 1 ≤ N ≤ 1000, 0 ≤ value in set ≤ 109
Subtask #2: 25 points
1 ≤ T ≤ 5, 1 ≤ N ≤ 105, 0 ≤ value in set ≤ 1000
Subtask #3: 55 points
1 ≤ T ≤ 5, 1 ≤ N ≤ 105, 0 ≤ value in set ≤ 109
Example
Input:
3
2
1 2
3
1 2 3
4
1 2 3 4