• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

a guest Nov 19th, 2019 97 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. #include <iostream>
2. #include <iomanip>      // std::setprecision
3.
4.
5. using namespace std;
6.
7. long double getNThProb(int n, double long x){
8.     long double sol = x*1.0;
9.     for(int i = 2; i <= n; i++){
10.         sol = sol + (1-sol)*x;
11.     }
12.     return sol;
13. }
14.
15. long double initProbs[100]={0,0.1, 0.1, 0.6, 0.455652142}, sumProbs[100], incraseRate[100]={0,0.1, 0.1, 0.6, 0.455652142};
16. int main(){
17.     int n = 4;
18.     int k = 4;
19.
20.     for(int iter = 1; iter <= k; iter++){
21.         int poz = 1;
22.         for(int i = 1; i <= n; i++){
23.             if (incraseRate[i] > incraseRate[poz]){
24.                 poz = i;
25.             } else if(incraseRate[i] == incraseRate[poz]){
26.                 if(initProbs[i] > initProbs[poz]){ //recheck
27.                     poz=i;
28.                 }
29.             }
30.         }
31.         sumProbs[poz] += (1-sumProbs[poz])*initProbs[poz];
32.         incraseRate[poz] = (1-sumProbs[poz])*initProbs[poz];
33.     }
34.
35.     double long result=0.0;
36.     for(int i = 1; i <= n; i++){
37.         result += sumProbs[i];
38. //        cout<<initProbs[i]<<' '<<sumProbs[i]<<' '<<incraseRate[i]<<'\n';
39.     }
40.     cout<<setprecision(7)<<result;
41.
42.     return 0;
43. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top