Advertisement
Guest User

Untitled

a guest
Mar 14th, 2020
561
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <map>
  4. #include <set>
  5. #include <utility>
  6. #define ll long long
  7. #define vii vector<vector<int>>
  8. #define pii pair<int, int>
  9. using namespace std;
  10. vector<ll> solve(ll u, ll v) {
  11. if (u > v || (u & 1) != (v & 1))
  12. return {-1};
  13. else if (u == 0 && v == 0)
  14. return {};
  15. else if (u == v)
  16. return {u};
  17. else if ((u & ((v - u) / 2)) == 0)
  18. return {u + (v - u) / 2, (v - u) / 2};
  19. else
  20. return {u, (v - u) / 2 , (v - u) / 2};
  21. }
  22. int main() {
  23. ll u, v;
  24. cin >> u >> v;
  25. auto ans = solve(u, v);
  26. if (ans.empty())
  27. cout << 0;
  28. else if (ans[0] == -1)
  29. cout << -1;
  30. else {
  31. cout << ans.size() << endl;
  32. for (int k : ans)
  33. cout << k << ' ';
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement