题解 | #Hello I am HERE!#
Hello I am HERE!
https://ac.nowcoder.com/acm/problem/15902
高精度模板题 读入,反转,去除前置零
之后高精度模板 再反转即可
using namespace std;
int main()
{
int t;
cin>>t;
while(t--) {
string a,b;
cin>>a>>b;
reverse(a.begin(), a.end());
reverse(b.begin(), b.end());
while(a[a.size()-1] == '0') a.erase(a.size()-1);
while(b[b.size()-1] == '0') b.erase(b.size()-1);
vector<int> var;
int t = 0;
for(int i = 0; i < a.size() || i < b.size(); ++i) {
if(i < a.size()) t += a[i] - '0';
if(i < b.size()) t += b[i] - '0';
var.push_back(t%10);
t /= 10;
}
if(t) var.push_back(1);
reverse(var.begin(), var.end());
for(auto &a: var) cout<<a;
cout<<endl;
}
}