fork download
  1. #include<bits/stdc++.h>
  2.  
  3. #define ll long long
  4. #define Add_Speed ios_base::sync_with_stdio(0);cin.tie(NULL);
  5. #define pb push_back
  6. #define mp make_pair
  7. #define f first
  8. #define sz size()
  9. #define int ll
  10. #define s second
  11. #define pii pair<int, int>
  12. #define all(s) s.begin(), s.end()
  13. #define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
  14.  
  15. using namespace std;
  16.  
  17. const int maxn = (int)1e5 + 100;
  18. const int M = (int)2e6 + 100;
  19. const int mod = (int)1e9 + 7;
  20. const int inf = mod;
  21.  
  22. int n, a[maxn], s, cnt[60][2];
  23. main () {
  24. cin >> n >> s;
  25. for(int i = 1; i <= n; i++){
  26. cin >> a[i];
  27. for(int j = 0; j < 60; j++){
  28. int bit = (a[i] >> j) & 1;
  29. cnt[j][bit]++;
  30. }
  31. }
  32. map<int, int> was;
  33. for(int i = 0; i < (1 << 20); i++){
  34. int res = 0, val = 0;
  35. for(int j = 0; j < 20; j++){
  36. int bit = ((i >> j) & 1);
  37. val += bit * (1ll << j);
  38. res += cnt[j][bit ^ 1] * (1ll << j);
  39. }
  40. was[res] = val;
  41. }
  42. for(int i = 0; i < (1 << 20); i++){
  43. int res = 0, val = 0;
  44. for(int j = 0; j < 20; j++){
  45. int bit = ((i >> j) & 1);
  46. val += bit * (1ll << (j + 20));
  47. res += cnt[j + 20][bit ^ 1] * (1ll << (j + 20));
  48. }
  49. if(was[s - res]){
  50. cout << was[s - res] + val;
  51. return 0;
  52. }
  53. }
  54. cout << -1;
  55.  
  56.  
  57. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:23:1: error: C++ requires a type specifier for all declarations
main () {
^
1 error generated.
stdout
Standard output is empty