提交时间:2022-07-19 12:38:32
运行 ID: 52528
#include <bits/stdc++.h> using namespace std; #define int long long int k, m, h, l, r, a, b, c, n; int geta(int x) { int ans = 0, p = x >> 1; for (int i = 0; i <= k; i++) { ans = (ans << 1) | (p & 1); p >>= 1; } if (x & 1) ans ^= (n - 1); return ans; } int f(int l, int r) { int ans = 0; if (l & 1) ans += geta(l); if (r & 1) ans += geta(r); return ans; } signed main() { scanf("%lld%lld%lld%lld%lld%lld%lld", &k, &m, &l, &r, &a, &b, &c); n = (1 << k); h = 0; for (int i = 1; i <= m; i++) { int gh = h, gl = l, gr = r; h = ((gl ^ gr ^ gh ^ f(gl, gr)) + c) % 1000000007; l = ((gl ^ a ^ h) % (n + 1)) % n; r = ((gr ^ b ^ h) % (n - l)) + l; } printf("%lld\n", h); }