#include <bits/stdc++.h> using namespace std; void pre(string &s) { int n = s.length(); int i = 0; while (s[i] == '0') ++i; s = s.substr(i, n); //清除前导零 reverse(s.begin(), s.end()); //竖式右对齐 } string slove(string a, string b) { pre(a), pre(b); int lena = a.length(), lenb = b.length(); if (lena < lenb) swap(a, b), swap(lena, lenb); //竖式加法,位数更高的放上面 string ans; bool f = 0; //标记进位 int i = 0; while (i < lenb) { int now = a[i] - '0' + b[i++] - '0' + f; //当前值 ans.push_back(now % 10 + '0'); //个位 f = now / 10; //进位 } while (i < lena) { int now = a[i++] - '0' + f; ans.push_back(now % 10 + '0'); f = now / 10; } if (f) ans.push_back('1'); //最后的进位 reverse(ans.begin(), ans.end()); //换回来 return ans; } int main() { int T; cin >> T; string a, b; for (int i = 1; i <= T; ++i) { cin >> a >> b; if (i - 1) putchar('\n'); cout << "Case " << i << ":\n" << a << " + " << b << " = "; cout << slove(a, b) << '\n'; } return 0; }