Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma warning(disable: 4996)
- #pragma comment(linker,"/STACK:64000000")
- #include <iostream>
- #include <sstream>
- #include <stdio.h>
- #include <memory.h>
- #include <algorithm>
- #include <set>
- #include <map>
- #include <string>
- #include <cstring>
- #include <vector>
- #include <cmath>
- #include <queue>
- #include <deque>
- #include <stack>
- #include <time.h>
- #include <cstdlib>
- #include <stdlib.h>
- using namespace std;
- #define mp make_pair
- #define pb push_back
- #define _(a) memset( (a), 0, sizeof( a ) )
- #define all(a) a.begin(), a.end()
- #define sz(a) (int)a.size()
- #define forpl(i, a, b) for(int i = a; i <= b; i++)
- #define forn(i, n) for(int i = 0; i < n; i++)
- #define formn(i, a, b) for(int i = a; i >= b; i--)
- #define foreach(it, a) for(auto it = a.begin(); it != a.end(); ++it)
- typedef unsigned long long ull;
- typedef long long lint;
- typedef pair < int , int > pii;
- typedef long double ld;
- const int INF = 1000 * 1000 * 1000;
- const lint LINF = 1000000000000000000LL;
- const double eps = 1e-9;
- string s, t;
- vector <int> A, B;
- int main()
- {
- #ifndef _DEBUG
- freopen("input.txt", "r", stdin);
- #endif
- int n, k;
- cin >> n;
- forn(i, n)
- {
- cin >> s >> t;
- A.clear();
- B.clear();
- formn(j, sz(s)-1, 0) A.push_back(s[j]-'0');
- formn(j, sz(t)-1, 0) B.push_back(t[j]-'0');
- k = sz(A) > sz(B) ? sz(A) : sz(B);
- forn(j, k-sz(A)+1) A.push_back(0);
- forn(j, k-sz(B)+1) B.push_back(0);
- forn(j, k)
- {
- A[j] += B[j];
- A[j+1] += A[j] / 2;
- A[j] %= 2;
- }
- cout << i+1 << " ";
- forn(j, k) cout << A[j];
- if (A[k] > 0) cout << A[k];
- cout << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement