Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
97111 | wzj33300 | 折纸 | C++ | 运行超时 | 30 | 4000 MS | 8436 KB | 5101 | 2023-08-09 12:10:04 |
#include <bits/stdc++.h> // #include <atcoder/all> // using namespace atcoder; using namespace std; // #define int long long typedef long long ll; typedef unsigned long long ul; typedef unsigned int ui; typedef pair<int, int> P; #define rep(i, s, n) for (int i = (s); i <= (n); ++i) #define per(i, n, s) for (int i = (n); i >= (s); --i) #define rep_(i, s, n) for (int i = (s); i < (n); ++i) #define per_(i, n, s) for (int i = (n); i > (s); --i) #define FOR(i, s, e, step) for (int i = s; i <= e; i += step) #define FOR_(i, s, e, step) for (int i = s; i < e; i += step) #define fora(i, v) for (auto i : (v)) #define fori(i, v) for (auto i = (v).begin(); i != (v).end(); ++i) #define all(v) (v).begin(), (v).end() #define all(v, n) (v) + 1, (v) + (n) + 1 typedef pair<ll, ll> LP; typedef double ld; typedef pair<ld, ld> LDP; const ld eps = 1e-10; const ld pi = acosl(-1.0); const ll mod = 1e9 + 7; template <typename T> void chmin(T& a, T b) { a = min(a, b); } template <typename T> void chmax(T& a, T b) { a = max(a, b); } ll qpow(ll x, ll n, ll m = mod) { if (n < 0) { ll res = qpow(x, -n, m); return qpow(res, m - 2, m); } if (abs(x) >= m) x %= m; if (x < 0) x += m; ll res = 1; while (n) { if (n & 1) res = res * x % m; x = x * x % m; n >>= 1; } return res; } // mod should be <2^31 struct modint { int n; modint() : n(0) { ; } modint(ll m) { if (m < 0 || mod <= m) { m %= mod; if (m < 0) m += mod; } n = m; } operator int() { return n; } }; bool operator==(modint a, modint b) { return a.n == b.n; } bool operator<(modint a, modint b) { return a.n < b.n; } modint operator+=(modint& a, modint b) { a.n += b.n; if (a.n >= mod) a.n -= (int)mod; return a; } modint operator-=(modint& a, modint b) { a.n -= b.n; if (a.n < 0) a.n += (int)mod; return a; } modint operator*=(modint& a, modint b) { a.n = ((ll)a.n * b.n) % mod; return a; } modint operator+(modint a, modint b) { return a += b; } modint operator-(modint a, modint b) { return a -= b; } modint operator*(modint a, modint b) { return a *= b; } modint operator^(modint a, ll n) { if (n == 0) return modint(1); modint res = (a * a) ^ (n / 2); if (n % 2) res = res * a; return res; } ll inv(ll a, ll p) { return (a == 1 ? 1 : (1 - p * inv(p % a, a)) / a + p); } modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); } modint operator/=(modint& a, modint b) { a = a / b; return a; } const int max_n = 1 << 20; modint fact[max_n], factinv[max_n]; void init_f() { fact[0] = modint(1); for (int i = 0; i < max_n - 1; i++) { fact[i + 1] = fact[i] * modint(i + 1); } factinv[max_n - 1] = modint(1) / fact[max_n - 1]; for (int i = max_n - 2; i >= 0; i--) { factinv[i] = factinv[i + 1] * modint(i + 1); } } modint comb(int a, int b) { if (a < 0 || b < 0 || a < b) return 0; return fact[a] * factinv[b] * factinv[a - b]; } modint combP(int a, int b) { if (a < 0 || b < 0 || a < b) return 0; return fact[a] * factinv[a - b]; } ll gcd(ll a, ll b) { a = abs(a); b = abs(b); if (a < b) swap(a, b); while (b) { ll r = a % b; a = b; b = r; } return a; } // int dx[4] = { 1,0,-1,0 }; // int dy[4] = { 0,1,0,-1 }; ll n, nn, m, l, r, h, a, b, c; ll ca(ll x) { if (x & 1) { ll y = x - 1; return nn - ca(y); } ll as = 0; x >>= 1; rep_(i, 0, n) { if ((x >> i) & 1) as += 1 << (n - 1 - i); } return as; } ll f(ll l, ll r) { ll ans = 0; if (l & 1) { ans += ca(l); ans %= mod; int cc = r - l; if (cc & 1) ans += ca(r), ans %= mod; ans += nn * (cc / 2) % mod; ans %= mod; } else { int cc = r - l + 1; if (cc & 1) ans ^= ca(r), ans %= mod; if ((cc / 2) % 2) ans ^= nn, ans %= mod; } return ans; } void _sol() { cin >> n; nn = (1 << n) - 1; // rep(i, 0, nn) cout << ca(i) << " "; // cout << endl; cin >> m >> l >> r; cin >> a >> b >> c; rep(p, 1, m) { h = ((l ^ r ^ h ^ f(l, r)) + c) % mod; l = (l ^ a ^ h) % ((nn + 1) + 1) % (nn + 1); r = ((r ^ b ^ h) % (nn + 1 - l)) + l; } cout << h << endl; } // signed main() { int main() { //freopen("fold.in", "r", stdin); //freopen("fold.out", "w", stdout); // ios::sync_with_stdio(false); // cin.tie(0); int t; // cin >> t; t = 1; while (t--) { _sol(); } return 0; } /*tips: read pls use 'cin'; write pls use 'printf' or 'cout', use 'endl' instead of '\n'; debug pls use 'cerr'. remember to initialize variables, note that the array is out of bounds. */ /* 3 1 2 6 3 4 5 */ /* 3 709193 4 5 273035200 65685838 991992535 */