Created
September 3, 2014 18:02
-
-
Save LB--/ca097eb45bc7ef2e1e8d to your computer and use it in GitHub Desktop.
Wrote this to speed up my homework solving process instead of using excel.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
#include <cmath> | |
int main() | |
{ | |
std::vector<long double> v; | |
{ | |
long double d; | |
while(std::cin >> d) | |
{ | |
v.push_back(d); | |
} | |
} | |
long double r = 0.0; | |
std::size_t const end = std::pow(2u, v.size()); | |
for(std::size_t i = 1; i < end; ++i) | |
{ | |
long double t = 1.0; | |
for(std::size_t j = 0; j < v.size(); ++j) | |
{ | |
if((i >> j) & 1) | |
{ | |
t *= v[j]; | |
} | |
else | |
{ | |
t *= (1.0L - v[j]); | |
} | |
} | |
r += t; | |
} | |
std::cout << r << std::endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment