#include <bits/stdc++.h>
#define maxd 1<<10
using namespace std;
vector<int> x;
vector<int>::iterator it;
int k;
long d[maxd];
long a[11];
long long dem;
void check(vector <int> x) {
long sum=0;
for( it = x.begin()+1; it < x.end(); it++ ) {
if (*it ==1 ) sum += a[it-x.begin()];
}
if (sum <= (1 << k)) d[sum]++;
}
void ChinhHopLap(long i) {
for (long j=0; j<=1; j++) {
x[i]=j;
if (i==k) check(x);
else ChinhHopLap(i+1);
}
}
int main() {
std::cin >> k ;
for (int i=1; i<=k; i++) std::cin >> a[i];
x.resize(k+1, -1);
x[0]=0;
ChinhHopLap(1);
for (long i=0; i<maxd; i++)
if (d[i]==0) {
std::cout << i;
return 0;
}
}
Mọi người có thể giải thích cho em kí hiệu <<
trong chỗ 1 << k
là gì và có tác dụng gì không ạ. Em cảm ơn.