fork(1) download
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. unsigned count;
  8. cin>>count;
  9. vector<double> tb(count),mul(count+1);
  10. for(unsigned i=0;i<count;++i) cin>>tb[i];
  11. for(unsigned m=0,max=1U<<count;m<max;++m)
  12. {
  13. double v=1;
  14. unsigned pos=count;
  15. for(unsigned i=0,x=m;x;x>>=1,++i) if(x&1) { v*=-tb[i]; --pos; }
  16. mul[pos]+=v;
  17. }
  18. for(unsigned i=count;i<=count;--i) cout<<mul[i]<<' ';
  19. cout<<endl;
  20. return 0;
  21. }
Success #stdin #stdout 0s 3476KB
stdin
3
2 -2 1
stdout
1 -1 -4 4