Advertisement
Alexandre_lsv

Untitled

Mar 14th, 2016
308
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.20 KB | None | 0 0
  1. /*#include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. set<ll> simpl(ll s){
  5.     set<ll> lll;
  6.     for (ll i=2; i<s; i++){
  7.         if (s%i==0){
  8.             lll.insert(i);
  9.         }
  10.     }
  11.     return lll;
  12. }
  13. int main(){
  14.     for (ll n=0; n<10000; n++) {
  15.         cout << n << ':';
  16.         for (auto& j:simpl(n*n*n*n+n*n+1))
  17.             cout << j << ',';
  18.         cout << endl;
  19.     }
  20.     return 0;
  21. }*/
  22.  
  23.  
  24. /*#include <bits/stdc++.h>
  25. using namespace std;
  26. typedef long long ll;
  27. int main(){
  28.     double s1=1774, s2=1899;
  29.     for (int i=3; i<2108; i++)
  30.     {
  31.         double s3;
  32.         s3=(double)((double)s2+1.0)/s1;
  33.         cout << i << " : " << s3 << endl;
  34.         s1=s2;
  35.         s2=s3;
  36.     }
  37.     return 0;
  38. }*/
  39. #include <bits/stdc++.h>
  40.     #include <ctime>
  41. using namespace std;
  42. typedef long long ll;
  43. int main(){
  44.     ll count=0;
  45.     ll poscount=0;
  46.     srand(time(0));
  47.     for (int i=3; i<100000; i++)
  48.     {
  49.         set<ll> sett {0,1,2,3,4,5,6};
  50.         bool au[7] {};
  51.         bool b=false;
  52.         if ((rand() % 10)>2)
  53.             au[rand()%7]=true;
  54.         ll h=rand()%7;
  55.         sett.erase(h);
  56.         for(auto&k:sett){
  57.             if (au[k]){
  58.                 b=true;
  59.                 break;
  60.             }
  61.         }
  62.         if (!b)
  63.             if (au[h]){
  64.                 poscount++;
  65.                 count++;
  66.             }
  67.             else
  68.                 count++;
  69.     }
  70.     //cout << poscount << ' ' << count;
  71.     cout << (double)poscount*1.0/count;
  72.     return 0;
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement