Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma GCC optimize("Ofast")
- #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
- #include <bits/stdc++.h>
- #include <ext/rope>
- #include <ext/pb_ds/assoc_container.hpp>
- #define endl '\n'
- #define fixstd() ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
- #define precision(n) cout.setf(ios::fixed), cout.precision(n)
- #define all(arr) arr.begin(), arr.end()
- #define rall(arr) arr.rbegin(), arr.rend()
- #define sz(arr) int(arr.size())
- #define sqr(n) ((n) * (n))
- #define print(arr) {for (auto el: arr) cout << el << ' '; cline();}
- #define pprint(A) for (auto &x: A) print(x)
- #define cprint(A) {for (auto &x: A) cout << x.fi << ',' << x.se << ' '; cline();}
- #define read(arr) for (auto &el: arr) cin >> el
- #define make_uniq(arr) sort(all(arr)), arr.resize(unique(all(arr)) - arr.begin());
- #define inc(arr) for (auto &x: arr) ++x
- #define dec(arr) for (auto &x: arr) --x
- #define multitest() int _; cin >> _; for (; _; --_)
- #define yesno(fl) (fl ? "YES" : "NO")
- #define out(n) cout << n << endl, exit(0);
- #define write(n) cout << n << endl
- #define debug(s, n) cout << s << ": " << n << endl
- #define cline() cout << endl
- #define pb push_back
- #define mp make_pair
- #define fi first
- #define se second
- using namespace std;
- using namespace __gnu_cxx;
- using namespace __gnu_pbds;
- typedef tree<int, null_type, less<int>, rb_tree_tag,
- tree_order_statistics_node_update> indexed_set;
- typedef long long lint;
- typedef long double ld;
- typedef string str;
- #define int lint
- typedef pair<int, int> col;
- typedef pair<lint, lint> coll;
- typedef pair<ld, ld> cold;
- typedef pair<str, str> cols;
- int A, B, C, D;
- inline int go(int x0, int x1) {
- return (A * x1 + B * x0 + C) % D;
- }
- int get_p(int x0, int x1) {
- int n;
- for (int i = 0; i < D; ++i) {
- n = go(x0, x1);
- x0 = x1, x1 = n;
- }
- int y0 = x0, y1 = x1;
- n = go(x0, x1);
- x0 = x1, x1 = n;
- int p = 0;
- while (x0 != y0 || x1 != y1) {
- n = go(x0, x1);
- x0 = x1, x1 = n;
- ++p;
- // cout << x0 << z' ' << x1 << ' ' << x2 << endl;
- }
- return p;
- }
- int get_n(int p, int x0, int x1) {
- int y0 = x0, y1 = x1;
- for (int i = 0; i <= p; ++i) {
- int n = go(y0, y1);
- y0 = y1, y1 = n;
- }
- int i;
- for (i = 0; x0 != y0; ++i) {
- int n = go(x0, x1);
- x0 = x1, x1 = n;
- n = go(y0, y1);
- y0 = y1, y1 = n;
- }
- return i;
- }
- ld get_q(int x0, int x1) {
- vector<int> cnt(20, 0);
- for (int i = 0; i < 400; ++i) {
- // int g = i / 20;
- // int left = g * p, right = (g + 1) * p;
- int n = go(x0, x1);
- for (int j = 0; j < 20; ++j) {
- if (j * D <= 20 * n && 20 * n < (j + 1) * D) {
- ++cnt[j];
- break;
- }
- }
- x0 = x1, x1 = n;
- }
- // print(cnt);
- int ans = 0;
- for (int i = 0; i < 20; ++i)
- ans += sqr(cnt[i] - 20);
- return (ld)ans / 400;
- }
- signed main() {
- precision(2);
- cin >> A >> B >> C >> D;
- int x0, x1; cin >> x0 >> x1;
- int p = get_p(x0, x1);
- // debug('p', p);
- int n = get_n(p, x0, x1);
- // debug('n', n);
- ld q = get_q(x0, x1);
- cout << ++p << ' ' << n << ' ' << q << endl;
- }
Add Comment
Please, Sign In to add comment