2019牛客暑期多校训练营(第七场)J A+B problem

链接:https://ac.nowcoder.com/acm/contest/887/J
来源:牛客网

题目描述

Reversed number is a number written in arabic numerals but the order of digits is reversed. The first digit becomes last and vice versa. And all the leading zeros are omitted.
For example: the reversed number of 1234 is 4321. The reversed number of 1000 is 1.

We define reversed number of 2019牛客暑期多校训练营(第七场)J A+B problem as 2019牛客暑期多校训练营(第七场)J A+B problem. Given you two positive integers 2019牛客暑期多校训练营(第七场)J A+B problem and 2019牛客暑期多校训练营(第七场)J A+B problem, you need to calculate the reversed sum: 2019牛客暑期多校训练营(第七场)J A+B problem.

输入描述:

The first line of the input gives the number of test cases, T (T≤300)T (T leq 300)T (T300). 2019牛客暑期多校训练营(第七场)J A+B problem test cases follow.

For each test case, the only line contains two positive integers: 2019牛客暑期多校训练营(第七场)J A+B problemand 2019牛客暑期多校训练营(第七场)J A+B problem. (1≤A,B≤231−11 leq A, B leq 2^{31}-11A,B2311)

输出描述:

For each test case, output a single line indicates the reversed sum.
示例1

输入

复制
3
12 1
101 9
991 1

输出

复制22
11
2


思路:  
本来想用高精度来求,反噬却总是wa,只能看大佬代码
#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>
using namespace std;

#define ll long long
#define eps 1e-9

const int inf = 0x3f3f3f3f;
const int mod = 1e9+7;

ll f(ll a)
{
    ll t = 0;
    while(a)
    {
        t = t * 10 + a % 10;
        a /= 10;
    }
    return t;
}

ll a, b;

int main()
{
    int t;
    for(scanf("%d", &t); t--; )
    {
        scanf("%lld%lld", &a, &b);
        printf("%lld
", f(f(a) + f(b)));
    }
    return 0;
}