Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include<iostream>
- #include<algorithm>
- #include<stdio.h>
- #include<vector>
- #include<set>
- #include<map>
- #include<string>
- #include<queue>
- #include<math.h>
- #include<deque>
- #define ll long long
- #define ld long double
- using namespace std;
- bool get_random(ll n) {
- for (ll i = 0; i < n; i++)
- if (rand() % 2)
- return false;
- return true;
- }
- const ll inf = 1ll << 62;
- const int exp_cnt = 1000;
- ll get_number(ll pwr) {
- if (pwr > 62)
- return inf;
- return 1ll << pwr;
- }
- const ll eps = 1ll << 12;
- bool experiment(ll n) {
- ll sum = 0;
- for (ll i = 1; i <= n; i++) {
- if (get_random(i))
- sum += get_number(i);
- if (sum > n * eps)
- return true;
- }
- return false;
- }
- bool probability(ll n) {
- for (int i = 0; i < exp_cnt; i++)
- if (experiment(n))
- return true;
- return false;
- }
- void solve() {
- ll n = 1;
- ll ex = 0;
- for (; ; n++) {
- if (experiment(n)) {
- cout << "Experiment # " << n << ". Result: explosion. Last explosion: " << ex << endl;
- ex = n;
- }
- else
- cout << "Experiment # " << n << ". Result: success. Last explosion: " << ex << endl;
- }
- }
- int main()
- {
- solve();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement