Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1. /*
  2. ,##. ,==.
  3. ,# #. \ o ',
  4. # # _ _ \ \
  5. # # (_) (_) / ;
  6. `# #' / .'
  7. `##' "=="
  8. */
  9.  
  10. #include <iostream>
  11. #include <fstream>
  12. #include <vector>
  13. #include <set>
  14. #include <map>
  15. #include <algorithm>
  16. #include <iomanip>
  17. #include <cmath>
  18. #include <ctime>
  19. #include <functional>
  20. #include <unordered_set>
  21. #include <unordered_map>
  22. #include <string>
  23. #include <queue>
  24. #include <deque>
  25. #include <stack>
  26. #include <complex>
  27. #include <cassert>
  28. #define ll long long
  29. #define null NULL
  30. #define all(a) a.begin(), a.end()
  31. #define debug(a) cerr << #a << " = " << a << endl
  32. #define forn(i, n) for (int i = 0; i < n; ++i)
  33.  
  34. using namespace std;
  35.  
  36. const ll MOD = 1e9 + 7;
  37.  
  38. ll power(ll x, ll deg) {
  39. ll res = 1;
  40. while (deg > 0) {
  41. if ((deg & 1LL) == 0) {
  42. x = (x * x) % MOD;
  43. deg >>= 1LL;
  44. }
  45. else {
  46. res = (res * x) % MOD;
  47. deg -= 1;
  48. }
  49. }
  50. return res;
  51. }
  52.  
  53. ll inverse(ll x) {
  54. return power(x, MOD - 2);
  55. }
  56.  
  57. const int mx = 62;
  58. const int lg_ll = 63;
  59.  
  60. int first1_ll(ll x) {
  61. if (x == 0)
  62. return -1;
  63. int z = __builtin_clzll(x);
  64. return lg_ll - z;
  65. }
  66.  
  67. vector<ll> get(vector<ll> a) {
  68. vector<ll> res;
  69. int n = a.size();
  70. for (int i = 0; i < n; ++i) {
  71. ll x = a[i];
  72. for (int j = 0; j < res.size(); ++j) {
  73. if (first1_ll(x) == first1_ll(res[j])) {
  74. x ^= res[j];
  75. }
  76. }
  77. if (x != 0)
  78. res.push_back(x);
  79. sort(res.rbegin(), res.rend());
  80. }
  81. return res;
  82. }
  83.  
  84. void check_get_function() {
  85. int n;
  86. cin >> n;
  87. vector<ll> a(n);
  88. for (int i = 0; i < n; ++i) {
  89. cin >> a[i];
  90. }
  91. vector<ll> b = get(a);
  92. cout << b.size() << endl;
  93. for (int i = 0; i < b.size(); ++i) {
  94. cout << b[i] << " ";
  95. }
  96. cout << endl;
  97. }
  98.  
  99. ll n, c, m, k;
  100.  
  101. int main() {
  102. cin >> n >> c >> m;
  103. vector<ll> a(m);
  104. for (int i = 0; i < m; ++i) {
  105. cin >> a[i];
  106. }
  107. vector<ll> b = get(a);
  108. k = b.size();
  109. if (n == 0) {
  110. cout << c << endl;
  111. return 0;
  112. }
  113. ll power2n = (1LL << n);
  114. ll power2n1 = (1LL << (n - 1));
  115. ll power2k = power(2, k);
  116. ll up = (power(c, power2n1) * (power2k - 1) + power(c, power2n)) % MOD;
  117. ll ans = (up * inverse(power2k)) % MOD;
  118. cout << ans << endl;
  119. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement