HackerEarth Alice and Bob buy crackers problem solution YASH PAL, 31 July 2024 In this HackerEarth, Alice and Bob buy crackers problem solution Alice and Bob want to buy firecrackers. There are N types of firecrackers available in the market with an ID I ranging from 1 to N. The cost of each firecracker is Ci. Each firecracker can be bought at most once. Bob’s father allows him to spend all the money in any way but his only condition is that Alice and Bob receive equal amounts of money. Your task is to determine the number of different amounts of money both can receive from Bob’s father. You are given the cost of all crackers and the money according to the condition provided. In other words, let S be a set. For each subset of firecrackers, if the sum of the costs of these firecrackers is even, then add their sum to S and print the size of S. Note that the set does not contain equal elements. HackerEarth Alice and Bob buy crackers problem solution. #include<bits/stdc++.h>#define hell 1000000007#define lcm(a,b) ((a*b)/__gcd(a,b))#define ll long long#define vll vector<ll>#define vi vector<int>#define pll vector< pair<ll,ll> >#define pb push_back#define mp make_pair#define all(v) v.begin(),v.end()#define lbnd lower_bound#define ubnd upper_bound#define bs binary_search#define F first#define S second#define rep(i,a,b) for(i=a;i<b;i++)#define parr(a,n) for(ll it=0;it<n;it++) cout<<a[it]<<" ";cout<<endl;#define pcont(a) for(auto it:a) cout<<it<<" ";cout<<endl;#define ret(x) return cout<<x,0;#define endl 'n'/*constants*/#define MAXN 100005#define PI 3.14159265358979323846/*debug*/#define TRACE#ifdef TRACE#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__) template <typename Arg1>void __f(const char* name, Arg1&& arg1){ std::cout << name << " : " << arg1 << 'n';} template <typename Arg1, typename... Args>void __f(const char* names, Arg1&& arg1, Args&&... args){const char* comma = strchr(names + 1, ','); std::cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);}#else#define trace(...)#endifusing namespace std;int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL); ll i,j,n,m,k,cnt=0,t=1; cin>>n; int c[n]; for(int i=0;i<n;i++){ cin>>c[i]; } set<int> ans; for(int i=1;i<(1<<n);i++){ int val=0; for(int j=0;j<n;j++){ if(i&(1<<j)) val+=c[j]; } if(val%2==0) ans.insert(val); } cout<<ans.size(); return 0;} coding problems