fork download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define int int64_t
  6. const int maxn = 1 << 17, mod = 1e9 + 7;
  7. int cnt[maxn], pows[maxn];
  8. int n;
  9.  
  10. int calc(int k)
  11. {
  12. return pows[n - k] * (pows[k] - 1) % mod;
  13. }
  14.  
  15. int get(int x, int y, int z)
  16. {
  17. int sum = 0;
  18. sum += calc(cnt[x]) + calc(cnt[y]) + calc(cnt[z]);
  19. sum -= calc(cnt[x | y]) + calc(cnt[y | z]) + calc(cnt[x | z]);
  20. sum += calc(cnt[x | y | z]);
  21. sum = (sum + mod) % mod;
  22. return x * y * z % mod * sum;
  23. }
  24.  
  25. main()
  26. {
  27. //freopen("input.txt", "r", stdin);
  28. //freopen("output.txt", "w", stdout);
  29. ios::sync_with_stdio(0);
  30. cin.tie(0);
  31. pows[0] = 1;
  32. for(int i = 1; i < maxn; i++)
  33. pows[i] = 2 * pows[i - 1] % mod;
  34. cin >> n;
  35. for(int i = 0; i < n; i++)
  36. {
  37. int a;
  38. cin >> a;
  39. for(int x = 1; x < maxn; x <<= 1)
  40. for(int y = x; y < maxn; y <<= 1)
  41. for(int z = y; z < maxn; z <<= 1)
  42. {
  43. if(y == z && y != x)
  44. continue;
  45. int num = x | y | z;
  46. if((a & num) != 0)
  47. cnt[num]++;
  48. }
  49. }
  50. int ans = 0;
  51. for(int x = 1; x < maxn; x <<= 1)
  52. for(int y = 1; y < maxn; y <<= 1)
  53. for(int z = 1; z < maxn; z <<= 1)
  54. ans = (ans + get(x, y, z)) % mod;
  55. cout << ans << "\n";
  56.  
  57. }
Success #stdin #stdout 0.01s 5508KB
stdin
Standard input is empty
stdout
0