Advertisement
Alexandre_lsv

Untitled

Mar 14th, 2016
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.65 KB | None | 0 0
  1.  
  2. #include <bits/stdc++.h>
  3. #include <ctime>
  4. using namespace std;
  5. typedef long long ll;
  6. int main(){
  7.     srand(time(0));
  8.     ll n=1;
  9.     ll count=0;
  10.     ll poscount=0;
  11.     for (ll t=0; t<20; t++){
  12.         n*=10;
  13.         for (ll i=0; i<n; i++)
  14.         {
  15.             set<ll> sett {0,1,2,3,4,5,6};
  16.             bool au[7] {};
  17.             bool b=false;
  18.             if ((rand() % 10)>2)
  19.                 au[rand()%7]=true;
  20.             ll h=rand()%7;
  21.             sett.erase(h);
  22.             for(auto&k:sett){
  23.                 if (au[k]){
  24.                     b=true;
  25.                     break;
  26.                 }
  27.             }
  28.             if (!b)
  29.                 if (au[h]){
  30.                     poscount++;
  31.                     count++;
  32.                 }
  33.                 else
  34.                     count++;
  35.         }
  36.         //cout << poscount << ' ' << count;
  37.         cout << (double)poscount*1.0/count << endl;
  38.     }
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement