fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. long long Count(long long s, long long x) {
  5. long long diff = s - x;
  6. if (diff < 0 || diff % 2) return 0;
  7. long long c = diff / 2;
  8. if ((c & x) != 0) return 0;
  9. int cnt = __builtin_popcountll(x);
  10. long long total = 1LL << cnt;
  11. if (c == 0 && x > 0) total -= 2;
  12. return total;
  13. }
  14.  
  15. int main() {
  16. freopen("sumxor.inp", "r", stdin);
  17. freopen("sumxor.out", "w", stdout);
  18. long long s, x;
  19. cin >> s >> x;
  20. cout << Count(s, x) << "\n";
  21. }
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
Standard output is empty