Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- // tiom4eg's precompiler options
- // POGGERS POGGERS POGGERS POGGERS POGGERS POGGERS POGGERS
- // IO settings
- #define fastIO ios_base::sync_with_stdio(false); cin.tie(0)
- // Quick types
- #define ll long long
- #define ld double
- #define ull unsigned long long
- #define pii pair <int, int>
- #define pll pair <ll, ll>
- #define vi vector <int>
- #define mi vector <vector <int> >
- // Quick functions
- #define endl "\n"
- #define F first
- #define S second
- #define all(a) a.begin(), a.end()
- #define sz(a) a.size()
- #define pb push_back
- #define mp make_pair
- #define min(a, b) ((a < b) ? (a) : (b))
- #define max(a, b) ((a > b) ? (a) : (b))
- // Quick fors
- #define FOR(i, a, b) for (int i = a; i < b; ++i)
- #define RFOR(i, a, b) for (int i = a; i >= b; --i)
- // Pragmas
- #pragma GCC optimize("O3,unroll-loops") // let the chaos begin!
- #pragma GCC target("avx,avx2,bmi,bmi2,popcnt,lzcnt,tune=native")
- #pragma GCC comment(linker, "/stack:200000000")
- // PBDS
- #include <ext/pb_ds/assoc_container.hpp>
- #include <ext/pb_ds/tree_policy.hpp>
- #define ordered_set tree <int, null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update>
- #define ook order_of_key
- #define fbo find_by_order
- // POGGERS POGGERS POGGERS POGGERS POGGERS POGGERS POGGERS
- using namespace std;
- using namespace __gnu_pbds;
- mt19937 rd(std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count());
- int rng(int n) { return rd() % n + 1; } // [1; n]
- // Simulation settings
- const int ITER = 66666, GEN = 1000;
- const int U = 25, D = 25, L = 25, R = 25; // 25%
- // Statistics
- double dist = 0.0;
- void sim() {
- int x = 0, y = 0;
- FOR(i, 0, ITER) {
- int cv = rng(U + D + L + R);
- if (cv <= U) y += 1;
- else if (cv <= U + D) y -= 1;
- else if (cv <= U + D + L) x -= 1;
- else x += 1;
- }
- dist += sqrt(x * x + y * y);
- }
- int main() {
- cout << fixed << setprecision(6);
- cout << "simulating " << GEN << " generations with " << ITER << " iterations each" << endl;
- FOR(i, 0, GEN) sim();
- cout << "done" << endl;
- cout << "avg dist: " << dist / (double)GEN;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement