CSES - E4590 2016 2 - Results
Submission details
Task:Fixed points
Sender:ivan
Submission time:2016-09-24 16:22:05 +0300
Language:C++
Status:READY
Result:
Test results
testverdicttime
#10.53 sdetails

Code

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>

using namespace std;

using ll = unsigned long long;

ll a, b;

ll f(ll x) {
    return ((a * x) ^ b);
}

int main(int argc, char *argv[])
{
    int t;
    cin >> t;

    for (int i = 0; i < t; ++i) {
        cin >> a >> b;
//        cout << a;

        ll x = 1;

        int iters = 0;

        while (true) {
            if (iters % 1000 == 0) {
                x = (ll)( ((ll)rand() << 48) | ((ll)rand() << 32)| ((ll)rand() << 16)| (ll)rand());
            }
//            cout << x << endl;
            iters += 1;
            ll r = f(x);
//            cout << r << endl;
            if (r == x || iters > 2000) {
                break;
            } else {
                x = r;
            }
        }

        if (iters > 2000) {
            cout << "-\n";
        } else {
            cout << x << "\n";
        }
    }

    return 0;
}

Test details

Test 1

Verdict:

input
100000
12865169357617740396 294321893...

correct output
5903494652862419412
-
13008184152928659765
9415006529485574473
16201136572240455608
...

user output
5903494652862419412
-
13008184152928659765
9415006529485574473
16201136572240455608
...