提交时间:2022-07-19 12:04:34
运行 ID: 52382
#include <bits/stdc++.h> using namespace std; typedef unsigned long long ull; const ull DVS = 1e9 + 7; ull K, M, H, L, R, A, B, C; ull N, mns1; ull funcA(ull x) { ull ans(0), p(x >> 1); for (ull i(0); i != K; ++i) ans = (ans << 1) | (p & 1), p >>= 1; if (x & 1) ans ^= mns1; return ans; } inline ull funcF(ull l, ull r) { if (l & 1) { if (r & 1) { return funcA(l) + ((r - l) >> 1) * mns1; } return funcA(l) + funcA(r) + ((r - l) >> 1) * mns1; } if (r & 1) { return (r - l + 1) & 2 ? mns1 : 0; } return ((r - l) & 2 ? mns1 : 0) ^ funcA(r); } int main() { // freopen("fold.in", "r", stdin); // freopen("fold.out", "w", stdout); cin >> K >> M >> L >> R >> A >> B >> C; N = (1ULL << K); mns1 = N - 1; while (M--) { H = ((L ^ R ^ H ^ funcF(L, R)) % DVS + C) % DVS; L = ((L ^ A ^ H) % (N + 1)) % N; R = ((R ^ B ^ H) % (N - L)) + L; } cout << H << endl; return 0; }