#include <iostream> #include <vector> using namespace std; int a[26];//存储前25个素数 bool is_prime(int n) { if (n == 1) return false; for (int i = 2; i <= n / i; i++) { if (n % i == 0) return false; } return true; } void func() { for (int i = 2, index = 0; index < 26; i++) { if (is_prime(i)) a[index++] = i; } } vector<int> add(vector<int>& A, vector<int>& B) { int t = 0; vector<int> C; for (int i = 0; i < A.size() || i < B.size(); i++) { if (i < A.size()) t += A[i]; if (i < B.size()) t += B[i]; C.push_back(t % a[i]); t /= a[i]; } if (t) C.push_back(t); //最高位进位不要忘记 return C; } int main() { //预处理素数数组 func(); // for (int i = 0; i < 26; i++) cout << a[i] << " "; // cout << endl; string a, b; cin >> a >> b; vector<int> A, B; for (int i = a.size() - 1; i >= 0; i--) { if (isdigit(a[i])) { int j = i; while (j >= 0 && isdigit(a[j])) j--; //j+1~i是一个数字 int num = 0; for (int k = j + 1; k <= i; k++) num = 10 * num + a[k] - '0'; A.push_back(num); i = j + 1; //因为i--以后指向下一个逗号 } } for (int i = b.size() - 1; i >= 0; i--) { if (isdigit(b[i])) { int j = i; while (j >= 0 && isdigit(b[j])) j--; //j+1~i是一个数字 int num = 0; for (int k = j + 1; k <= i; k++) num = 10 * num + b[k] - '0'; B.push_back(num); i = j + 1; //因为i--以后指向下一个逗号 } } vector<int> res = add(A, B); for(int i=res.size()-1;i>=0;i--){ cout<<res[i]; if(i==0) break; cout<<","; } return 0; }