Advertisement
Guest User

Untitled

a guest
Jan 20th, 2017
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.04 KB | None | 0 0
  1. #include "testlib.h"
  2. #include <vector>
  3. #include <algorithm>
  4. #include <iostream>
  5. #include <queue>
  6. #include <map>
  7. #include <cassert>
  8. #include <cstdio>
  9. #include <string>
  10. #include <time.h>
  11. #include <iomanip>
  12. #include <cmath>
  13. #include <stack>
  14. #include <set>
  15.  
  16. using namespace std;
  17.  
  18.     const int INF = 1e9;
  19.  
  20.     const int MAXLEN = 62;
  21.  
  22. vector<int> toBin(long long x)
  23. {
  24.     vector<int> result;
  25.     while (x)
  26.     {
  27.         result.push_back(x % 2);
  28.         x /= 2;
  29.     }
  30.     reverse(result.begin(), result.end());
  31.     return result;
  32. }
  33.  
  34. void solve(int argc, char* argv[])
  35. {
  36.     registerValidation(argc, argv);
  37.    
  38.     long long a = inf.readLong(0, 1000000000000000000LL, "a");
  39.     inf.readSpace();
  40.     long long b = inf.readLong(0, 1000000000000000000LL, "b");
  41.     inf.readEoln();
  42.  
  43.     vector<int> A = toBin(a);
  44.     vector<int> B = toBin(b);
  45.     ensuref(A.size() + B.size() <= MAXLEN, "Too large expecting answer");
  46.  
  47.     inf.readEof();
  48. }
  49.  
  50. int main(int argc, char* argv[])
  51. {
  52. #ifdef _DEBUG
  53.     freopen("input.txt", "r", stdin);
  54. #endif
  55.     //srand(time(NULL));
  56.  
  57.     solve(argc, argv);
  58.  
  59.     return 0;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement