HDU 5680 zxa and set(数学的導出結論)
2180 ワード
zxa and set
テーマリンク:
http://acm.hust.edu.cn/vjudge/contest/121332#problem/G
Description
zxa has a set,which has elemens and obviousy non-empty subsets.
For each subset of,which has elemens,zxa defined its value as.
zxa is is interested to know、asuming that represents the sum of the values of the non n-empy sets、in which each set is a subset of and the number of elemens ininininisodd、andrepresents the sum the the sum of the the the vavavanes s the emmmthe the the the the the the varerererererererererererererererererereemmmmms 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 s s s s s s s s s s the e of,can you help him?
Input
The first line contains an positive integer、represents there test cases.
For each test case:
The first line contains an positive integer、represents the number of the set is.
The second line contains distinct positive integers、repersent the elements.
The e e e e is a blank between each integer with no other extra space in one line.
Output
For each test case,output in one line a non-negative integer,repersent the value of.
Sample Input
3 1 10 3 1 2 4 1 2 3 3 3 4
Sample Output
10 3 4
ベント
件名:
集合Aを与え、BはAの任意のサブセットである。あるセットの値をセット要素の最小値として定義します。S-oddは元素の個数が奇数のBの個数である。S-evenは元素の個数が偶数のBの個数である。abs(S-odd-S-even)を求めます。
クイズ:
面倒そうに見えますが、何回か計算します。各要素が結果に現れる回数を組み合わせの数として書いてみます。また、題意に合わせて組み合わせの数に関する公式を使うと、簡単に得られます。結果はAの中の最大値です。
コード:
テーマリンク:
http://acm.hust.edu.cn/vjudge/contest/121332#problem/G
Description
zxa has a set,which has elemens and obviousy non-empty subsets.
For each subset of,which has elemens,zxa defined its value as.
zxa is is interested to know、asuming that represents the sum of the values of the non n-empy sets、in which each set is a subset of and the number of elemens ininininisodd、andrepresents the sum the the sum of the the the vavavanes s the emmmthe the the the the the the varerererererererererererererererererereemmmmms 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 s s s s s s s s s s the e of,can you help him?
Input
The first line contains an positive integer、represents there test cases.
For each test case:
The first line contains an positive integer、represents the number of the set is.
The second line contains distinct positive integers、repersent the elements.
The e e e e is a blank between each integer with no other extra space in one line.
Output
For each test case,output in one line a non-negative integer,repersent the value of.
Sample Input
3 1 10 3 1 2 4 1 2 3 3 3 4
Sample Output
10 3 4
ベント
件名:
集合Aを与え、BはAの任意のサブセットである。あるセットの値をセット要素の最小値として定義します。S-oddは元素の個数が奇数のBの個数である。S-evenは元素の個数が偶数のBの個数である。abs(S-odd-S-even)を求めます。
クイズ:
面倒そうに見えますが、何回か計算します。各要素が結果に現れる回数を組み合わせの数として書いてみます。また、題意に合わせて組み合わせの数に関する公式を使うと、簡単に得られます。結果はAの中の最大値です。
コード:
#include
#include
#include
#include
#include
#define mid(a,b) ((a+b)>>1)
#define LL long long
#define maxn 600000
#define IN freopen("in.txt","r",stdin);
using namespace std;
int n;
int main(int argc, char const *argv[])
{
//IN;
int t;cin>>t;
while(t--)
{
scanf("%d",&n);
int ans = -1;
while(n--){
int x;
cin >> x;
ans = max(ans, x);
}
printf("%d
", ans);
}
return 0;
}
転載先:https://www.cnblogs.com/Sunshine-tcf/p/5697220.html