fork download
  1.  
  2. #include<bitset>
  3. #include<iostream>
  4. #include <stack>
  5. #include<algorithm>
  6. #include<map>
  7. #include<unordered_map>
  8. #include<unordered_set>
  9. #include<vector>
  10. #include<set>
  11. #include<queue>
  12. #include<cstdio>
  13. #include<random>
  14. #include<math.h>
  15. #include<numeric>
  16. #include<string>
  17. #include<fstream>
  18. #include<iomanip>
  19. #include <immintrin.h>
  20. #include <chrono>
  21. #define pq priority_queue
  22. #define qu queue
  23. #define ll long long
  24. #define Sroor_1000 ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  25. using namespace std;
  26. const int MOD = 1e9 + 7;
  27. int Gcd(int a, int b) {
  28. if (b == 0)return a;
  29. return Gcd(b, a % b);
  30. }
  31. bool test(int &a,int &b,int c,int &l) {
  32. for (int i = 0; i < c; i++) {
  33. if ((a - i) == b - (c - i)) {
  34. l = a - i;
  35. a = i;
  36. b = c - i;
  37. return false;
  38. }
  39. }
  40. return true;
  41. }
  42. int popcount(ll c) {
  43. return bitset<64>(c).count();
  44. }
  45. void solve() {
  46. bool q = true;
  47. int n, k = 0,l; ll c;
  48. cin >> n>>k>>c;
  49. if (n < k) { swap(n, k); q = false; }
  50. if (test(n, k, popcount(c),l)) {
  51. cout << -1;
  52. return;
  53. }
  54. bitset<64>t = c,one,two;
  55. for (int i = 0; i < 63&&l; i++) {
  56. if (t[i] != 1) {
  57. one[i] = two[i] = 1;
  58. l--;
  59. }
  60. }
  61. for (int i = 0;n||k; i++) {
  62. if (t[i] == 1) {
  63. if (n) {
  64. one[i] = 1;
  65. n--;
  66. }
  67. else {
  68. two[i] = 1;
  69. k--;
  70. }
  71. }
  72. }
  73. if(q) cout << one.to_ullong() << ' ' << two.to_ullong();
  74. else cout << two.to_ullong() << ' ' << one.to_ullong();
  75. // cout<<endl << (one.to_ullong()^two.to_ullong());
  76.  
  77. }
  78.  
  79.  
  80.  
  81.  
  82. int main() {
  83.  
  84. Sroor_1000
  85. /* FILE* IN, * out;
  86.   freopen_s(&IN,"stdin", "r", stdin);
  87.   freopen_s(&out,"stdout", "w", stdout);*/
  88. int t; t = 1;
  89. // cin >> t;
  90. while (t--)solve();
  91.  
  92.  
  93.  
  94. }
  95.  
  96.  
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
-1