Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- ,##. ,==.
- ,# #. \ o ',
- # # _ _ \ \
- # # (_) (_) / ;
- `# #' / .'
- `##' "=="
- */
- #include <iostream>
- #include <fstream>
- #include <vector>
- #include <set>
- #include <map>
- #include <algorithm>
- #include <iomanip>
- #include <cmath>
- #include <ctime>
- #include <functional>
- #include <unordered_set>
- #include <unordered_map>
- #include <string>
- #include <queue>
- #include <deque>
- #include <stack>
- #include <complex>
- #include <cassert>
- #define ll long long
- #define null NULL
- #define all(a) a.begin(), a.end()
- #define debug(a) cerr << #a << " = " << a << endl
- #define forn(i, n) for (int i = 0; i < n; ++i)
- using namespace std;
- const ll MOD = 1e9 + 7;
- ll power(ll x, ll deg) {
- ll res = 1;
- while (deg > 0) {
- if ((deg & 1LL) == 0) {
- x = (x * x) % MOD;
- deg >>= 1LL;
- }
- else {
- res = (res * x) % MOD;
- deg -= 1;
- }
- }
- return res;
- }
- ll inverse(ll x) {
- return power(x, MOD - 2);
- }
- const int mx = 62;
- const int lg_ll = 63;
- int first1_ll(ll x) {
- if (x == 0)
- return -1;
- int z = __builtin_clzll(x);
- return lg_ll - z;
- }
- vector<ll> get(vector<ll> a) {
- vector<ll> res;
- int n = a.size();
- for (int i = 0; i < n; ++i) {
- ll x = a[i];
- for (int j = 0; j < res.size(); ++j) {
- if (first1_ll(x) == first1_ll(res[j])) {
- x ^= res[j];
- }
- }
- if (x != 0)
- res.push_back(x);
- sort(res.rbegin(), res.rend());
- }
- return res;
- }
- void check_get_function() {
- int n;
- cin >> n;
- vector<ll> a(n);
- for (int i = 0; i < n; ++i) {
- cin >> a[i];
- }
- vector<ll> b = get(a);
- cout << b.size() << endl;
- for (int i = 0; i < b.size(); ++i) {
- cout << b[i] << " ";
- }
- cout << endl;
- }
- ll n, c, m, k;
- int main() {
- cin >> n >> c >> m;
- vector<ll> a(m);
- for (int i = 0; i < m; ++i) {
- cin >> a[i];
- }
- vector<ll> b = get(a);
- k = b.size();
- if (n == 0) {
- cout << c << endl;
- return 0;
- }
- ll power2n = (1LL << n);
- ll power2n1 = (1LL << (n - 1));
- ll power2k = power(2, k);
- ll up = (power(c, power2n1) * (power2k - 1) + power(c, power2n)) % MOD;
- ll ans = (up * inverse(power2k)) % MOD;
- cout << ans << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement