Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as C++ by sn ( 17 years ago )
void brute() {
int *t,wa,pa,naj,wmax=0,max=0;
for(unsigned long long i=0;i<(unsigned long long)pow(2,n);i++) {
t = new int[n];
for(int j=0;j<n;j++) t[j]=0;
for(int j=i,s=0,;j>=1;j/=2,s++) t[n-1-s]=j%2;
pa = wa = 0;
for(int j=0;j<n;j++) {
if(wa+w[j]>c) break;
else {
if(t[j]==1) { wa+=w[j]; pa+=v[j]; }
}
}
if(pa>max) { max=pa; naj=i; wmax=wa; }
}
wynik2.push_back(wmax);
wynik2.push_back(max);
for(int j=naj,s=0,;j>=1;j/=2,s++) if(j%2==1) wynik2.push_back(n-s);
}
Revise this Paste