#include#include #include #include #include using namespace std;const int Bit = 1000000000;const int Max_N = 20010;struct BigNumber { long long num[Max_N]; int len; BigNumber () { len = 0; memset(num, 0, sizeof num); } BigNumber (long long A) { len = 0; while (A) { num[++ len] = A % Bit; A /= Bit; } } void Clear() { len = 0; memset(num, 0, sizeof num); } BigNumber operator = (const BigNumber &A) const { BigNumber ret; ret.len = A.len; for (int i = 1; i <= A.len; ++ i) { ret.num[i] = A.num[i]; } return ret; } BigNumber operator + (const BigNumber &A) const { BigNumber ret; ret.len = max(A.len, len) + 3; for (int i = 1; i <= len; ++ i) { ret.num[i + 1] += (A.num[i] + num[i]) / Bit; ret.num[i] += (A.num[i] + num[i]) % Bit; } while (!ret.num[ret.len] && ret.len) -- ret.len; return ret; } BigNumber operator - (const BigNumber &A) const { BigNumber ret = *this; ret.len = max(len, A.len) + 2; for (int i = 1; i <= A.len; ++ i) { ret.num[i] -= A.num[i]; if (ret.num[i] < 0) { ret.num[i] += Bit; ret.num[i + 1] --; } } while (!ret.num[ret.len] && ret.len) -- ret.len; return ret; } BigNumber operator * (const BigNumber &A) const { BigNumber ret; ret.len = len + A.len + 3; for (int i = 1; i <= len; ++ i) { for (int j = 1; j <= A.len; ++ j) { long long v = 1LL * num[i] * A.num[j] + ret.num[i + j - 1]; ret.num[i + j] += v / Bit; ret.num[i + j - 1] += v % Bit; } } while (!ret.num[ret.len] && ret.len) -- ret.len; return ret; } BigNumber operator / (const int &A) const { BigNumber ret; ret.len = len + 3; for (int i = ret.len; i > 0; -- i) { ret.num[i - 1] = (ret.num[i] + num[i]) % A * Bit; ret.num[i] = (ret.num[i] + num[i]) / A; } ret.num[0] = 0; while (!ret.num[ret.len] && ret.len) -- ret.len; return ret; } void Read() { Clear(); static char S[1000010]; scanf("%s", S + 1); int N = strlen(S + 1); long long Pow = 1; for (int i = N; i; -- i) { if (Pow == 1) ++ len; num[len] += (S[i] - '0') * Pow; Pow *= 10; if (Pow == Bit) Pow = 1; } } void Write() { printf("%lld", num[len]); for (int i = len - 1; i > 0; -- i) { printf("%09lld", num[i]); } }} ;namespace WorkSpace { void Main() { BigNumber A; A.Read(); long long B; scanf("%lld", &B); BigNumber(B).Write(); puts(""); (A * BigNumber(B)).Write(); return ; }}int main() { WorkSpace :: Main(); return 0;}
——QAQ%%%yjl