Skip to content

Instantly share code, notes, and snippets.

@OmarJH
Created May 12, 2015 12:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OmarJH/a7e1fb39af0758661a8f to your computer and use it in GitHub Desktop.
Save OmarJH/a7e1fb39af0758661a8f to your computer and use it in GitHub Desktop.
edited
#include <iostream>
#include <vector>
using namespace std;
int main()
{
double h=0;
double p1, p2, p3;
int n;
cin >> p1;
cin >> p2;
cin >> p3;
cin >> n;
if (((n-1)/5) %2 !=0 )
h = p1*(1 - p3) + (p3)*(1 - p2);
else
h = h + p1*p3 + (1 - p3)*(1 - p2);
cout << h << endl;
cin >> h;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment