Cod sursa(job #2827734)

Utilizator razviii237Uzum Razvan razviii237 Data 6 ianuarie 2022 11:44:44
Problema A+B Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.13 kb
#include <iostream>
#include <fstream>

using namespace std;

ifstream f("xor3.in");
ofstream g("xor3.out");

const int maxn = 1005;

/*
void testMatrix() {
    int a[maxn][maxn];
    int n, i, j;
    f >> n;
    g << "0 ";
    for(i = 1; i <= n; i ++) {
        a[0][i] = i;
        g << a[0][i] << ' ';
    }
    g << '\n';
    for(i = 1; i <= n; i ++) {
        g << "0 ";
        for(j = 1; j <= n; j ++) {
            a[i][j] = a[i-1][j] ^ a[i][j-1];
            g << a[i][j] << ' ';
        }
        g << '\n';
    }
}
*/

const int maxn = 1e6+5;

typedef long long lint;
lint q, x, y, a, b, m;
int lg[maxn];

void solve(lint x, lint y) {
    /*
    if(y % 2 == 0) {
        x -= (x / y) * (y);
    } else {
        x -= (x / (y + 1)) * (y + 1);
    }
    */
    x -= (x / (1 << (lg[y] + 1))) * (1 << (lg[y] + 1));
}

int main()
{
    for(i = 2; i <= maxn - 5; i ++) {
        lg[i] = lg[i >> 1] + 1;
    }
    //testMatrix();
    f >> q >> x >> y >> a >> b >> m;
    while(q --) {
        solve(x, y);

        x = (a * x + b) % m;
        y = (a * y + b) % m;
    }

    return 0;
}