#include #include #include void decomp(int *tab, int taille, int m) { for(int i=0; i>=1; } int subsetsum(int *ensemble, int taille, int m) { int base2[taille], i, j, somme, max=1<m) return -1; if(subsetsum_recursif(ensemble, taille, profondeur+1, m, somme+ensemble[profondeur])==1) return printf("%d ", ensemble[profondeur]), 1; return subsetsum_recursif(ensemble, taille, profondeur+1, m, somme); } int subsetsum_recursif2(int *ensemble, int taille, int profondeur, int m, int somme) { if(somme==m) return 0; if(taille==profondeur) return -1; if(somme>m) return -1; int r=subsetsum_recursif2(ensemble, taille, profondeur+1, m, somme+ensemble[profondeur]); if(r>=0) return r+(1<=0) return r+(1<<(n-1)); } return subr2(t,n-1,s); } int somme(int*t, int m) { int s=0; for(;m;m>>=1,t++) if(m&1) s+=*t; return s; } typedef int subs(int*,int ,int); void test(int n,subs sub,const char*nom,unsigned z) { int t[n], i, nn=(1<=0 && ts[i]+st[j]!=s) if(ts[i]+st[j]x;j--) t[j]=t[j-1]; } int ttt(int*t,int*u,int m) // somme(t,m)=somme(u,ttt(t,u,m)) si t[] est une permutation de u[]. { int p=0, i, j; // On permute les bits de m, comme on permute t[] pour obtenir u[]. for(i=0;m;i++) if(m>>i&1) { for(j=0;(p>>j&1) || t[i]!=u[j];j++) ; p+=1<